Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ItemManager 2.0
Hello Bigin,

thank you for the time you spent to help me. As expected, your code works great, and one thing I still couldn't find out is how to implement the enabled/disabled (active) state into my code. Here is what I got so far. I know it's terribly wriiten but I find it really difficult to understand OOP as a beginner... :-) Please ignore the inline styles, they will be replaced later with classes.

PHP Code:
<?php
$slug 
get_page_slug(false);
$page get_site_url(false);
$manager = new IManager();
if(!
$manager){die('ItemManager not installed!');}
$kategorie $manager->getCategoryMapper()->getCategory('name=Angebote');
if(!
$kategorie){die('Angebote category does not exist!');}
$itemClass $manager->getItemClass();
$itemClass->init($kategorie->id);
$itemClass->filterItems('position''ASC'); // updated

foreach($itemClass->items as $item) {

 
   echo "<div class=\"".strtolower(htmlspecialchars($item->fields->package->value))."\">\r\n";

 
     if(!empty($item->fields->visibleonhome->value) == 1) {
 
         echo '<div style="margin: 10px 10px 0 0; display: block; float: right; border-radius: 50%; background: green; width: 15px; height: 15px;"></div>';
 
     }

 
     if(!empty($item->fields->image->value)) {
 
         $imageTitle $manager->sanitizer->text($item->fields->image->title[0]);
 
         $imageUrl $manager->sanitizer->text($item->fields->image->fullurl[0]);
 
         echo "\t";
 
         echo '<div style="width: 40%; float: left;"><img alt="'.$imageTitle.'" src="'.$page.$imageUrl.'" /></div>';
 
         echo "\r\n";
 
     }

 
     echo "\t<div style=\"width: 60%; float: left; padding: 0 30px 30px 30px;\">\r\n";
 
     echo "\t<h1>" htmlspecialchars($item->name) . "</h1>";
 
     echo "\r\n";

 
     if(!empty($item->fields->package->value)) {
 
         echo "\t<p class=\"category ".strtolower(htmlspecialchars($item->fields->package->value))."\">" htmlspecialchars($item->fields->package->value) . "</p>";
 
         echo "\r\n";
 
     }

 
     if(!empty($item->fields->teaser->value)) {
 
         echo $item->fields->teaser->value "";
 
         echo "\r\n";
 
     }

 
     if(!empty($item->fields->more->value)) {
 
         echo "\t<a href=\"#\" class=\"more\">" $item->fields->more->value "<i class=\"fa fa-angle-right\" aria-hidden=\"true\"></i></a>";
 
         echo "\r\n";
 
     }
 
     else {
 
       echo "\t</div>\r\n";
 
     }

 
     if(!empty($item->fields->content->value) && !empty($item->fields->more->value)) {
 
         echo "\t<span class=\"hidden\">" $item->fields->content->value "</span>";
 
         echo "\r\n";
 
         echo "\t</div>\r\n";
 
     }

 
   echo "</div>\r\n\r\n";
}
?>

Thank you very much again and have a nice evening :-)
Reply
There are many ways of doing that. One option would be to use getItems() method with "active=1" selector before filterItems():

PHP Code:
$itemClass->init($kategorie->id);
$items $itemClass->getItems('active=1');
$items $itemClass->filterItems('position''ASC'00$items);
foreach(
$items as $item) {
... 

Another option is even simpler – I think: Just check if the item is active inside your foreach construct, something like:

PHP Code:
foreach($itemClass->items as $item) {
    if(empty(
$item->active)) continue;
 
       ... 


Best regards
Reply
Amazing, Bigin! Thank you very much again. Your support has been so motivating that I decided to learn OOP.

Best wishes to you :-)
Reply
@Bigin, is there a reason for queue_style('imstylefonts', GSBOTH); ? because if I load FontAwesome separately, I need to modify the plugin. Couldn't find what is using it in frontend except of my template but there I have icomoon modified version of FontAwesome, so it basically loads twice the same content. For now I just modified it to GSBACK
Reply
Hi morvy,

I do not know why I have GSBOTH there, I see no reason for this. Yeah, just leave it set to GSBACK, I will change it with the next update.

Thanks for your reporting.
Reply
GS 3.3.13 PHP 5.6
in setinngs I've got a lot of notices like this
"Notice: Trying to get property of non-object in .../docs/plugins/imanager/lib/Admin.php on line 434"
and plugin doesn't work
Reply
(2017-02-07, 05:12:40)wakh Wrote: GS 3.3.13 PHP 5.6
in setinngs I've got a lot of notices like this
"Notice: Trying to get property of non-object in .../docs/plugins/imanager/lib/Admin.php on line 434"
and plugin doesn't work

There is too little information to make a reasonable answer. ItemManager works without any troubles with PHP 5.6
Reply
what's required?
tried on 2 different hostings
Reply
All your warnings and error messages.

But i think IM installation is damaged. Try to reinstall, delete all ItemManager folders and files in "/plugins/" and /data/imanager/ complete directory.
Reply
Thanks!
It was because i use "GS Plugin Installer" for install this, after reinstall it work!
May be you need to notice about it and/or add selfcheck to plugin.
Reply
Sure!

(2017-02-07, 06:13:43)wakh Wrote: May be you need to notice about it and/or add selfcheck to plugin.

Already there, but it will not work if PHP files are missing lol. I don't care about Plugin Installer, IM has its own installation routine.

regards
Reply
Hello Bigin,
 
when I try to upload an image it works fine on my local host. But when I try to upload an image on my server I get the following message in debug mode:

Error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

The image will be shown in the frontend but the thumbnail could not be created for the backend.

Do you have an idea how to solve this?

Thank you :-)
Reply
Hi smsHH,

hmmm, I have never seen anything like this. Is it javascript error on console? It's fairly difficult to diagnose your problem without a reproducible example.

Which field are you using "file upload" or the older "image upload"?

If you suspect that the error occurs during image cropping, you can check whether thumbnails are created under: "/data/uploads/imanager/1.15/thumbnail/your_image_file.jpg" where 1 is the item's id and 15 your category.

You can try with a different browser and check again whether error message is displayed.

You can also try to remove the "/data/uploads/imanager/*.*" folder and repeat the upload
Reply
Hello Bigin,

thank your for your quick response.

I am using 'file upload'.

When I create a new item and try to upload an image file, neither a folder for thumbnails will be created nor the thumbnail itself, Chrome reports (below the file upload dialogue):

Code:
Error SyntaxError: Unexpected token < in JSON at position 0

while Chrome's console reports:

Code:
GET http://path-to-my-server/admin/http//path-to-my-server/admin/template/js/fancybox/jquery.fancybox.pack.js [HTTP/1.1 404 Not Found 168ms]

NS_ERROR_UNEXPECTED:   eval line 1 > eval
    wrap2/< eval line 1 > eval
    .data http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:23037
    b/< http://path-to-my-server/plugins/imanager/upload/js/bootstrap.min.js:6:1832
    f</<.each http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:11935
    f</e.prototype.each http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:8481
    b http://path-to-my-server/plugins/imanager/upload/js/bootstrap.min.js:6:1795
    ._renderUpload http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload-jquery-ui.js:67:13
    $.widget/</proxiedPrototype[prop]</< http://path-to-my-server/plugins/imanager/upload/js/vendor/jquery.ui.widget.js:126:19
    .options.add http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload-ui.js:103:32
    $.Widget.prototype._trigger http://path-to-my-server/plugins/imanager/upload/js/vendor/jquery.ui.widget.js:518:4
    ._onAdd/< http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload.js:1033:26
    f</<.each http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:11935
    ._onAdd http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload.js:1026:13
    $.widget/</proxiedPrototype[prop]</< http://path-to-my-server/plugins/imanager/upload/js/vendor/jquery.ui.widget.js:126:19
    ._onChange/< http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload.js:1225:21
    f.Callbacks/n http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:14779
    f.Callbacks/o.add http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:14999
    .Deferred/h.always http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:16032
    ._onChange http://path-to-my-server/plugins/imanager/upload/js/jquery.fileupload.js:1215:13
    $.widget/</proxiedPrototype[prop]</< http://path-to-my-server/plugins/imanager/upload/js/vendor/jquery.ui.widget.js:126:19
    handlerProxy http://path-to-my-server/plugins/imanager/upload/js/vendor/jquery.ui.widget.js:434:14
    f.event.dispatch http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:3:4299
    f.event.add/i http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:3:311

Chrome also says that the fancybox js and css files couldn't be found.

Tried with the deleted folder but no success. Will try with a fresh install of GS and imanager...

Strange that it works on my local host but not on my server.

Hope you have further ideas :-) Thank you again.
Reply
(2017-02-11, 02:10:02)smsHH Wrote: Hope you have further ideas :-) Thank you again.

not really... ItemManager does not use fancybox, fancybox is a GS component. But, the URL you posted looks pretty messy lol: http://path-to-my-server/admin/http//path-to-my-server/admin/template/js/fancybox/jquery.fancybox.pack.js
I think, that your GS installation is wrecked, what is your "Website URL" in GS settings?
Reply
I am using the recommended website URL in the settings. I have tried it with a fresh install, the path to fancybox is correct now.

I activated only the ItemManager plug in. Same error occurs just right after clicking the 'Start upload' button:

Error SyntaxError: Unexpected token < in JSON at position 0

I found some solutions to solve this problem, maybe (and hopefully) it helps you:

https://www.google.de/search?q=Error+Syn...e&ie=UTF-8

Again, no folder for the thumbnails and no thumbnail will be created.

Would you mind checking this on a server? Thank you very much :-)
Reply
(2017-02-11, 06:10:21)smsHH Wrote: I am using the recommended website URL in the settings. I have tried it with a fresh install, the path to fancybox is correct now.

I activated only the ItemManager plug in. Same error occurs just right after clicking the 'Start upload' button:

Error SyntaxError: Unexpected token < in JSON at position 0

I found some solutions to solve this problem, maybe (and hopefully) it helps you:

https://www.google.de/search?q=Error+Syn...e&ie=UTF-8

Again, no folder for the thumbnails and no thumbnail will be created.

Would you mind checking this on a server? Thank you very much :-)

Hi smsHH,

This is a fairly common Javascript (front-end) error which means either a JSON data file request failed (might be a permissions issue on your server or with incompatible plugin .htaccess files), or the file is not properly formatted (might be an issue with one of your plugins, if it uses JSON. If this is the case you should be able to rule them out by disabling them one by one and seeing if the issue is still there). I suppose you've seen this in the browser console. Typically these errors include a stack trace. Click the little arrow on the left to open it, then click the link next to the @ symbol (see image below):

[Image: v0rkG03.png]

This will open up the Sources panel in the console, and should highlight the line of code which causes the error.
Ctrl + A copy the code from that file and add it here so we can further help you.
Reply
At first I thought that it was a permissions issue, but it looks like that there is no issue when saving of other data ...
Maybe, the problem occur during the cropping/resizing of the images, so you get a broken JSON Response.

PS. Take a look into the apache error log to see if IM submits any error messages.
Reply
Thank you very much for your help, Bigin & Tyblitz.

I have installed GS and IM on three different hosts now, on two of them it works perfectly but not on the third. After clicking the 'Start upload' button the following message appears in the Firefox Developers Edition console:

Cannot play media. No decoders for requested formats: image/jpeg, image/jpeg          load.php

The accepted file types for the file upload field are gif|jpe?g|png.

In Firefox: NS_ERROR_UNEXPECTED:   eval line 1 > eval    (same as in my entry #114)

Apache error log contains no error messages.

I thought it's maybe an .htaccess issue, renamend the file, no success. I checked the permissions for the folders, no success.

What a weekend ;-)

Thank you again for your help.
Reply
Just out of curiosity, which is the third one of the 3 hosts?
Reply
power-netz.de -> I have tested IM on several domain names with that provider - no success.

1&1 and terralink are okay...
Reply
Thank you smsHH.
Ahh ok, a no-name hoster, with an user interface that looks like it came from the last century. I think that we can just ignore it.
Reply
Thank you and sorry for my late response. Unfortunately the third host is mine but I will ask my provider what the issue could be...
Reply
ItemManager 2.3.8 is released

Recent changes:

NEW: Item Allocator class - makes easy and quickly work with a huge number of items (1000 >). Also, it simplifies the use of item object, as only the  "light-weigth" objects will be loaded into the memory, therefore overhead will be significant reduced. Usage example
NOTE: You can deactivate this function at any time via the "$this->useAllocater = false" in "/plugins/imanager/lib/inc/config.php" file.


NEW: FieldFilepicker - File picker field has been implemented, which makes it possible, using the functions of "i18n_customfields" plugin, the use of GetSimple native images and files from "uploads" directory - at this point many thanks to tomot for his help!
NOTE: This field is enabled only if "i18n_customfields" plugin is in the GS "/plugins/" directory (no installation is necessary).

MODIFICATION: CSS changes - Minimal style changes of pagination and field width.

MODIFICATION: FieldImageupload - Is deprecated and was replaced with newer FieldFileupload field. For compatibility reasons, the FieldImageupload's are still supported, though no longer available when selecting the fields in back-end.

BUGFIX: FieldDatepicker - When selecting the date, when the date format was not specified.

BUGFIX: FieldDatepicker - When you are use several date picker fields (thanks to tomot).

BUGFIX: Check reserved field names when you save category fields.

BUGFIX: Message Reporter - Multiple messages rendering.

BUGFIX: Setup - The date format issue (thanks to morvy for reporting this bug).

BUGFIX: Template Engine - fixed some minor bugs.

BUGFIX: FontAwesome - Restrict include to back-end (thanks to morvy).
Reply
Great, Bigin!

Now the datepicker works again :-) I get an error message though. After clicking the Confirm button when I created the datepicker field, this mesage appears:

Catchable fatal error: Argument 1 passed to Allocator::disalloc() must be an instance of int, string given, called in D:\xampp\htdocs\jk\plugins\imanager\lib\Model.php on line 489 and defined in D:\xampp\htdocs\jk\plugins\imanager\lib\Allocator.php on line 47

Luckily the datepicker field will be saved. Hope that message helps you.
Reply




Users browsing this thread: 1 Guest(s)
Free HDTV Channels Residential Solar Panels