HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Displaying number of records per categories of catalogue

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#36145 (In Topic #8131)
Avatar

Fan in action

Displaying number of records per categories of catalogue

 Hi All,

Question 1:
I got this catalogue page which displays all the categories that fall under it and the users have to click each category to view the entries under it. So how can i display the number of entries per category at the side of it. Eg ( Education (2) ) where 2 refers to the number of records.

Question 2:
I need to migrate data from my old database to the ocPortal database. During the migration time, some errors occurs due to the usage of special html characters like single quote, double quotes, etc etc, so i got no choice but to use html entities function to convert all applicable characters to html entities, meaning converting table's to table&#039s. The data migration was successfully done, However, what i didn't expect is that ocPortal didn't decode the html entities into the original characters, meaning what display out is table&#039s, instead of table's, so is there any ways which i can resolve this problem? I not sure if adding html_entity_decode() to whatever page will helps ? and i'm unsure of where to add this code too.

Thanks in advance, Great help is appreciated
Back to the top
 
Posted
Rating:
#36161
Avatar

Hi,

(1) - it does already doesn't it?

(2) - entity encoding shouldn't have been necessary, as ocPortal content is almost all stored as Comcode rather than HTML. You're probably best off testing editing one of your records by hand to prove that to yourself, then writing some kind of converter script to apply these changes en-masse. Perhaps a specific exception threw you off before, but I can't think what.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#36171
Avatar

Fan in action

Reply to Chris

Hi Chris,

(1) This is what i get. There is no number to state how many entries are there under each category. According to what u have mentioned, i think there might be something which i never tick to display the records, could you kindly point out to me how to do it?

(2) Could you point out to me which page does the displaying of catelogue entry?

Thanks alot.



Back to the top
 
Posted
Rating:
#36185
Avatar

(1) - Ah, I see this is the category index. You could switch to a tree catalogue, and then you'd see the subcategory tallies on the root category of that catalogue. However, I think it's perfectly reasonable to want the tallys on the index, so I'm going to make a patch…

Change line 2 of the INDEX_PAGE_ENTRY template to:

Code

   &raquo; <a href="{URL*}">{NAME*}</a>{+START,IF_PASSED,DISPLAY_STRING} {DISPLAY_STRING*}{+END}

Change 692 of site/pages/modules/catalogues.php from:

Code

         $out->attach(do_template('INDEX_PAGE_ENTRY',array('_GUID'=>'f2550f5be8765b5d0349ee5523f739cb','NAME'=>$name,'URL'=>$url)));
to:

Code

         $child_counts=count_catalogue_category_children($myrow['id']);
         $num_children=$child_counts['num_children'];
         $num_entries=$child_counts['num_entries_children'];
         if ($num_entries!=0)
         {
            if ($num_children>0)
            {
               $display_string=do_lang('CATEGORY_SUBORDINATE',number_format($num_entries),number_format($num_children));
            } else
            {
               $display_string=do_lang('CATEGORY_SUBORDINATE_2',number_format($num_entries));
            }
         } else
         {
            $display_string=do_lang('CATEGORY_SUBORDINATE_NO_ENTRIES');
         }

         $out->attach(do_template('INDEX_PAGE_ENTRY',array('_GUID'=>'f2550f5be8765b5d0349ee5523f739cb','NAME'=>$name,'URL'=>$url,'DISPLAY_STRING'=>$display_string)));
(2) - The CATALOGUE_DEFAULT_ENTRY_PAGE template does it. It contains {ENTRY} which could be replaced with something like:

Code

{$REPLACE,&quot;,",{$REPLACE,&amp;,&,{$REPLACE,&gt;,>,{$REPLACE,&lt;,<,{$REPLACE,&#039,',{ENTRY}}}}}}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#36196
Avatar

Fan in action

Thanks Chris, with the above code, i get what i want. So Right now, i'm going to try to do the qn2. hehe

Below is what i got:


and is what i want

Back to the top
 
Posted
Rating:
#36197
Avatar

Fan in action

For Qn 2, I paste the code into both the global.tpl and the catelogue default entry page.tpl and it works. Haha, Thanks alot Chris

Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: