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
#59
i can't insert picture and description if create new item.
Reply
#60
Unfortunately this is not enough information to be able to help you. Turn on error reporting and check your log file to see if there is a problem.
Reply
#61
Hi Bigin,

I have the same problem, I cant upload image without a script error (JSON)
The upload is done btw but at the end : " SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"
Image is uploaded but is not visible in the object's edit page.
Reply
#62
The same answer: see the log files
Reply
#63
(2020-04-13, 21:16:18)Bigin Wrote: The same answer: see the log files

Code:
PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message '$maxWidth must be numeric' in C:\xampp\htdocs\getsimple\plugins\imanager\phpthumb\GdThumb.inc.php:172
Stack trace:
#0 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\inc\_Util.php(64): GdThumb->resize(NULL, NULL)
#1 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php(696): ImCatalog\Util::getResizedUrl(Object(SimpleItem), 3, NULL, NULL, 'resize')
#2 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php(258): ImCatalog\Controller->__renderFrontendItemDetails()
#3 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php(523): ImCatalog\Controller->renderSection('FrontendItemDet...')
#4 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php(258): ImCatalog\Controller->__renderFrontendItemDetailsContent()
#5 C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php(214): ImCatalog\Controller->renderSection('FrontendItemDet...')
#6 C:\xampp\htdocs\getsimple\plugins\im_simpl in C:\xampp\htdocs\getsimple\plugins\imanager\phpthumb\GdThumb.inc.php on line 172
Reply
#64
Thanks.

Here's a problem resizing your pictures.

The error message you show relates to resizing the pictures in the frontend rather than in the admin area. The upload of the pictures in the admin works correctly, right?

How many pictures does your item contain?
Reply
#65
(2020-04-13, 23:07:57)Bigin Wrote: Thanks.

Here's a problem resizing your pictures.

The error message you show relates to resizing the pictures in the frontend rather than in the admin area. The upload of the pictures in the admin works correctly, right?

How many pictures does your item contain?

Yes sorry, that was not the good log...

Code:
[13-Apr-2020 15:36:27 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 693

[13-Apr-2020 15:36:27 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 694


It is in the admin. The upload works, I have the pic but I have this JSON alert too, dont know where it come from.
I thought it could come to spcial chars (à ç etc.) but I tried without and same error.
And I dont have the image in the admin item page (the thumb), the "images" section is empty.

Here is a screenshot :
https://ibb.co/0D9LHgT
Reply
#66
(2020-04-13, 23:20:40)Stéphane Wrote: Here is a screenshot :
https://ibb.co/0D9LHgT

This is just a message that returns upload controller, it can have many causes and it's important that we narrow it down. There must be an error message that occurs/logs during upload. Could you please keep your JavaScript console open during the upload, what is showing there?

Thx
Reply
#67
Sure, this is what I get (google translate)


Code:
This page uses the non-standard property "zoom". Consider using calc () in the values of the relevant properties or use "transform" with "transform-origin: 0 0". load.php
Unable to read media. No decoder for the necessary formats: image / jpeg, image / jpeg 3 load.php
Unable to read media. No decoder for the necessary formats: image / jpeg, image / jpeg   load.php
Reply
#68
It has no sense, I need original message in English. :-)

Have you tried another browser?
Reply
#69
(2020-04-13, 23:53:43)Bigin Wrote: It has no sense,  I need original message in English. :-)

Have you tried another browser?

The translation was good Smile

This is with Chrome :
https://ibb.co/dBX7M9D
https://ibb.co/Lh3GTLt

And in case, this is my errorlog.txt :

Code:
[13-Apr-2020 15:49:28 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 693

[13-Apr-2020 15:49:28 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 694

I'm on windows 10, last browsers versions, with xampp, php 5.6, no ghostery, no badger or adblocker.
Reply
#70
These messages have nothing to do with the actual issue:

(2020-04-14, 00:14:45)Stéphane Wrote: This is with Chrome :
https://ibb.co/dBX7M9D
https://ibb.co/Lh3GTLt

These only affect the frontend view, which we have already discussed earlier:

(2020-04-14, 00:14:45)Stéphane Wrote:
Code:
[13-Apr-2020 15:49:28 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 693

[13-Apr-2020 15:49:28 Europe/Berlin] PHP Notice:  Undefined offset: 3 in C:\xampp\htdocs\getsimple\plugins\im_simple_catalog\lib\controller.php on line 694


Please do the following:
1. Open admin page with the upload form in Chrome.
2. Open the JS-Console.
3. Now, click on the Clear Console button (this will empty the console output)

Next, start the upload until an error message is displayed and post it here.

Thx
Reply
#71
[quote pid='68274' dateline='1586788327']
Please do the following:
1. Open admin page with the upload form in Chrome.
2. Open the JS-Console.
3. Now, click on the Clear Console button (this will empty the console output)

Next, start the upload until an error message is displayed and post it here.

Thx
[/quote]

Sorry, but that exactly what I have done...

The log appeared on admin page load, nothing on upload img... That's on Chrome.

If I use Firefox :
1- when loading admin page

Code:
This page uses the non-standard property "zoom". Consider using calc () in the values of the relevant properties or use "transform" with "transform-origin: 0 0". load.php


2- Juste after I select the image (before upload)
Code:
Unable to read media. No decoder for the necessary formats: image / jpeg, image / jpeg 3 load.php

3- After download : the JSON error for the "title".
Reply
#72
(2020-04-14, 00:56:20)Stéphane Wrote: The log appeared on admin page load, nothing on upload img... That's on Chrome.

Hmm... then, the issue must be in Apache or PHP configuration.

PHP version?

By the way, did you comment out GSDEBUG in gsconfig.php file?
Reply
#73
(2020-04-14, 03:05:03)Bigin Wrote:
(2020-04-14, 00:56:20)Stéphane Wrote: The log appeared on admin page load, nothing on upload img... That's on Chrome.

Hmm... then, the issue must be in Apache or PHP configuration.

PHP version?

By the way, did you comment out GSDEBUG in gsconfig.php file?

Yes GSDEBUG is up.

Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31
And I use Xampp (laptop)

Tested on Edge, Firefox, Chrome and Opera, each time the same.
I'm back to original admin theme and I actually deactive plugins one by one.
Reply
#74
(2020-04-14, 03:22:24)Stéphane Wrote: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31
And I use Xampp (laptop)

Should be fine.

Curiously, if you say you get this error message:

https://ibb.co/0D9LHgT

... why don't you see it in your Chrome's Javascript Console?
Reply
#75
The fact that the < character is caused by PHP request, meaning no valid JSON is returned. In that case you must see a broken output in the console.
Reply




Users browsing this thread: 1 Guest(s)