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
#56
This relates to this question: http://get-simple.info/forums/showthread.php?tid=11166

Yes, you did it correct.

There are some ways you could do that.
If a simple redirect enough, you can add a statement to your template above, for example:

PHP Code:
if($catalog->processor->config->pageSlug == 'catalog') {
    
Util::redirect('./my-category/');


But in this case you will still see the URL like:  website.com/gallery/catalog/my-category/ and maybe that's not what you want...

Another way to accomplish this (like you already did) is to completely customize the output (see here: https://ehret-studio.com/articles/simple...og-output/) by using $catalog->renderSection() method:

Just create a page with the name and slug like your category e.g. 'my-category' (the adding of [[catalog_content]] isn't necessary in this case).
Next, replace the 'get_page_content()' function in your template with following statement:
PHP Code:
<?php
if(get_page_slug(false) == 'my-category') {
    
$catalog->renderSection('FrontendItemList', array('routeid' => 3));
    echo 
$catalog->content;
} else {
    
get_page_content();


NOTE: Change the 'routeid' => 3 with the id of your real category whose items you want to show. You can find out the id by going to GS Admin > ItemManager > Categories, then click on your category name.

(2019-07-23, 04:29:26)usderofit Wrote: Also, at the moment, when going to an items page (what i will use as an album) only one image is shown, how can i show all of the images in this item?

Maybe this'll help: http://get-simple.info/forums/showthread...3#pid61303

Good luck.
Reply
#57
Thanks for that!
I got most of it working, i changed the script in a few places, not sure if in the same way as you meant in your comment, but its working Smile

I think the last thing that i havent figured out yet is how to show all of the images that are related to the specific category.

To make things clearer, when im in:
website.com/gallery
I want to see all of the images that are inside the items in that category, so if i have category a, category b, and they both have 5 images, i want to see all of those images on the main /gallery/ page.

I tried your code but its rendering the section that outputs the category items instead of all of the images related to that category. Plus its rendering it in its own function and i cant add my own styles to it.
Reply
#58
You have to hook into $controller method to customize it, as described here: http://get-simple.info/forums/showthread...3#pid63413. To be more exact, you have to hook in __renderFrontendItemList() instead. To do that, you should expand your extender like this:

PHP Code:
...
public function 
renderSection($sectionName$params = array())
{
    if(
$sectionName == 'FrontendItemList') {
        
$this->renderFrontendItemList($params);
        ...


Then you have to write renderFrontendItemList($args = null) method, that replaces the default __renderFrontendItemList($args = null), see controller.php.
Attention to the potential conflicts between Util of the IM and Util of the SimpleCatalog, if you want to call the SC Util methods you'll need to use namespace in your im_sc_extender.php e.g:

PHP Code:
use ImCatalog\Util as U

Then you call it like this:

PHP Code:
U::getResizedUrl(...); 

In order to show all the items of all your categories, you have to paste the code from the __renderFrontendItemList($args = null) method into your renderFrontendItemList($args = null) and then change it a bit.
So, your method must look something like this (not tested): https://gist.github.com/bigin/e6cfffe54e...9203a1a767
Reply




Users browsing this thread: 1 Guest(s)