Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SimpleCatalog
#51
oh, cool, thank you!
Reply
#52
Try the script here:

https://gist.github.com/bigin/0d4805b093...1223e37f5d

Put the code somewhere in your template and visit the page once. If it works then remove the code again.
The code alters your dummy category with an extra field named 'group' and updates all existing categories so that new field can be used to sort the categories by the contents of the field.

Then you have to modify your Extender plugin additionally. A new method 'renderFrontendCategoryList()' should be implemented. Also you have to extend the renderSection() method there as well. Your new Extender methods might look like this:

https://gist.github.com/bigin/a18dfa929a...2eae1beaee
Reply
#53
perfect! it all worked perfectly.
Now im trying to actually display the group name when ever there is a new group.
So far its not working out, but im trying to do it in the loop with an if statement checking if its a new group each iteration, if so then add the group name to $rows, but so far its just outputing the name a lot (which makes sense since i dont know what is inside $rows exactly)
Reply
#54
The $rows variable is a string it contains parsed markup, so it's a bit late to work with it, you should start a little sooner to get the values. The variable $category contains all category data, which you can display as follows:
PHP Code:
private function renderFrontendCategoryList() { 
    ...
    if(isset(
$result['total']) && $result['total'] > && !empty($result['categories'])) {
 
       foreach($result['categories'] as $category) {
            ...
            
Util::preformat($category);
... 

If you want to access a category value, you can do it this way:
PHP Code:
...
$category->field_name
... 

To check if the previous category contains a different 'group' value you could extend your foreach loop as follows:
PHP Code:
...
foreach(
$result['categories'] as $key => $category) {
    ...
    
$replace['group'] = '';
    if(isset(
$result['categories'][$key-1]) && $result['categories'][$key-1]->group != $category->group) {
        
$replace['group'] = $category->group// where $replace['group'] is the placeholder name in your template
    
}
... 
Reply
#55
great! its working perfectly!

The if statement didnt show the first group so i updated the if statement to this:
if(!isset($result['categories'][$key-1]) || (isset($result['categories'][$key-1]) && $result['categories'][$key-1]->group != $category->group))

Its all working perfectly now!
Thanks a lot for your help!
Reply




Users browsing this thread: 1 Guest(s)