![]() |
ItemManager 2.0 - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13) +--- Thread: ItemManager 2.0 (/showthread.php?tid=7293) |
RE: ItemManager 2.0 - Felix - 2020-04-30 Hello, I noticed that ItemManager automatically creates thumbnails inside data/uploads/imanager/x.y/thumbnail/ How can I access the thumbnail pictures url when doing a foreach ? Code: $imanager = imanager(); RE: ItemManager 2.0 - Bigin - 2020-04-30 Hi, you can create any thumbnails you want with IM. There http://get-simple.info/forums/showthread.php?tid=7293&pid=68514#pid68514 I showed you a function, that lets you create thumbnails in any sizes you want. Try it. RE: ItemManager 2.0 - Felix - 2020-04-30 Hi, I want to select an item that holds 5 photos Then I want to do a for each loop to store from the image field the fullurl and title in the variables $url and $title that I can use to echo html. Is it possible to do this with only 1 for each loop ? The following for each loop does not put the fullurl and title in the variables: Code: $imanager = imanager(); How can I do this with one for each loop ? Do I need to use a separate for-each loop to get each field property ? RE: ItemManager 2.0 - Bigin - 2020-04-30 (2020-04-30, 06:08:28)Felix Wrote: How can I do this with one for each loop ? Hmm... I see only one foreach in your example? Like this, perhaps: PHP Code: foreach ($my_item->fields->image->fullurl as $key => $fullurl) ? RE: ItemManager 2.0 - Felix - 2020-04-30 Hi Bigin, First of all, thanks for pointing me to the use of $key in foreach loops I can confirm that the following code now is working: Code: <?php Outputting html for galleries, sliders, banners, etc. in websites is asked for a lot so having a foreach loop doing that in ImManager is very practical. $my_item must be some kind of array in ImManager. Are there other ways to loop through and output the array elements ? This is what I have found so far: Code: <?php RE: ItemManager 2.0 - Bigin - 2020-04-30 Hello, your "$my_item" variable is an object of type Item, not an array. What is the point of outputting all Item object properties? Especially since they are always the same for each Item of that category type and only the values differ? Would you please explain what you're trying to accomplish so I may better help you? If you just want to see how your item object is structured you can easily check it using the Util::preformat($my_item) function. RE: ItemManager 2.0 - Felix - 2020-04-30 Quote:Would you please explain what you're trying to accomplish so I may better help you? Your help with ImManager is very complete, thanks again for that. But maybe a little history will be on it's place. I come from a different cms with a powerful but over-engineered api with mysql as a database. Since I discovered that with xml a website is much, much faster I switched to the GS cms. Also the use of xml apps or plugins such as ImManager keeps everything modular. You only install what is needed for a website and keep everything else out. But I still have to get used to the differences in api usage. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Yes the use of Util::preformat($my_item); is very good for debugging and see what is possible to accomplish I have added it to my tool box ! RE: ItemManager 2.0 - Felix - 2020-05-01 Hi, In one of the items I am using a WYSIWYG field with the name description and use this to output the contents on the front: <?php echo $my_item->fields->description->value; ?> It's working ok with only text in the WYSIWYG editor, but as soon as I insert an image the image does not show up on the front. The image shows up correctly inside the WYSIWYG editor with this url: <p><img alt="" src="http://localhost/items/data/uploads/my-company.png" style="float: left; width: 243px; height: 200px;" /></p> But on the front the url shows up like is: http://localhost/items/%22http://localhost/items/data/uploads/my-company.png%22 Any idea why the url on the front is wrong ? RE: ItemManager 2.0 - Bigin - 2020-05-01 Hi Felix, are you sure it's the URL that messed up? Did you have a look at the URL in "Source View" (not browser console!)? As far as I remember there was a problem formatting "double quotes" from WYSIWYG. If it is the double quotes that are causing the problems, you can solve it with the html_entity_decode(): html_entity_decode($my_item->fields->description->value); RE: ItemManager 2.0 - Felix - 2020-05-01 Hi Bigin, Thanks for your reply. You are right about the double quotes. When I checked on View Page Source the double quotes were replaced by: & # 3 4 (without the spaces between the characters as this post will convert it back to ") using html_entity_decode($my_item->fields->description->value); did solve it ! Thanks. RE: ItemManager 2.0 - Felix - 2020-05-03 Hello Bigin, The ItemManager plugin is working perfectly when I use it only from the GS backend under the tab Manager. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - However I seem to have a problem using ItemManager from the pages in the GS backend. When I select a page in the GS backend and then go to options there is an option to select a Category. When I select a Category I can see the fields of that Category. Then I enter, for example, in the Text field some text and click on Save. Then when I go back to the Tab Manager I can see that a new item has been added to the Catecory. The new item has been given a name like: 3052675811 However when I try to output the text from this item there is no output. $itemMapper->init(6); // Category 6 holds the item 3052675811 $items = $itemMapper->items; $this_item = $itemMapper->getItem('name=3052675811'); <?php echo ($this_item->fields->text->value); ?> Also when I try to delete this item there is an error message that says: "Item does not exist" What am I doing wrong ? RE: ItemManager 2.0 - Bigin - 2020-05-03 Hello, I have no idea. I can't reproduce it. Everything works for me. Maybe you get messed up saving it? Did you tried to select the item by its id? PHP Code: $item = $itemMapper->getItem(3052675811); By the way, you can also select your item by page slugs: PHP Code: $item = $itemMapper->getItem( RE: ItemManager 2.0 - Felix - 2020-05-03 Hi Bigin, Thanks for your reply. Yes when I use 2147483647 then it is working: $this_item = $itemMapper->getItem('2147483647'); <?php echo html_entity_decode($this_item->fields->editor->value); ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - However, when I go back to the page and want to add some more text to the field and click on Save, the following error shows up: Error: & # 6 0 ; div & # 6 2 ;Error saving item & # 6 0 ; /div & # 6 2;. Error: <div >Error saving item</div>. - - - - - - - - - - - - - - - - - - - - - - - - - - - When I go back to the tab Manager and check there the item I see that: pos = 2147483647 name = 3052675811 When I click on 3052675811 I see that the id = 2147483647 RE: ItemManager 2.0 - Bigin - 2020-05-03 hmm. no idea. It may be that the ID no longer matches the page name? When using the IM Extra Pages, you should decide on its editing method. RE: ItemManager 2.0 - Felix - 2020-05-03 Quote:When using the IM Extra Pages, you should decide on its editing method. Hi Bigin, Thanks for your reply What do you mean by "you should decide on it's editing method ? RE: ItemManager 2.0 - Bigin - 2020-05-03 I mean: prefer the editing of items inside "Extra Pages" interface instead of the editing with IM. Otherwise there is the potential to mess up something and accidentally overwrite the item name. RE: ItemManager 2.0 - Felix - 2020-05-03 Hi Bigin Good news I reinstalled everything and this time I did choose another page and another category, and now everything is working correctly. Not sure what the problem was. Thanks for all the help. Now I am ready to start building with ItemManager. I want to build a GS theme with the content driven by ItemManager and upload to the GS repository. I will post back on this. RE: ItemManager 2.0 - Bigin - 2020-05-03 Great, have fun! ;-) RE: ItemManager 2.0 - Felix - 2020-05-13 Hi, When I deactivate the plugins ItemManager and IM Extra Fields, then logically <?php echo html_entity_decode($home_item->fields->editor->value); ?> does not output anything anymore but GS page content <?php get_page_content(); ?> does also stop to output content When I activate again the plugins ItemManager and IM Extra Fields, then also <?php get_page_content(); ?> outputs again it's content How is this possible ? <?php get_page_content(); ?> should work independent from the ItemManager plugin RE: ItemManager 2.0 - Felix - 2020-05-13 Hi, When I deactivate the plugins ItemManager and IM Extra Fields, and remove this code on the template file: Code: <?php then <?php get_page_content(); ?> outputs again it's content Is this normal behaviour ? RE: ItemManager 2.0 - Bigin - 2020-05-13 Hi Felix, this has absolutely no relation to the get_page_content() function. It's quite simple, if the ItemManager is disabled, your code above will cause an error, since you turned off error reporting in gsconfig.php you won't get it visible. It is therefore highly recommended to enable error reporting during code development, and if you are programming procedurally, it is always preferable to use the function_exists() to wrap your ItemManager code: PHP Code: if(function_exists('imanager')) { RE: ItemManager 2.0 - Felix - 2020-05-13 Hi Bigin, Yes you are right: I should have turned on DEBUG Mode ! and so I did. Yep, an error message popped up $imanager = imanager() is undefined on line ... wich makes sense when I have the ItemManager plugins disabled. And so on turn when I deleted all ItemManager code in my template so did the error message disappear and <?php get_page_content(); ?> started to work again. I guess I created some unnecessary fuzz. It all makes sense. RE: ItemManager 2.0 - Felix - 2020-05-13 I stopped writing ItemManager code in my website page template files. Instead I am writing ItemManager code as a php function() in the functions.php file Like I did for this Gallery: Code: function photobox() { Now, with a simple <?php photobox(); ?> in a page template file I can make this Gallery popup anywhere I want - this is great ![]() Also this way contributes to better separation of code and html layout RE: ItemManager 2.0 - Bigin - 2020-05-14 (2020-05-13, 21:24:23)Felix Wrote: Also this way contributes to better separation of code and html layout Yes, that's good idea. It was a good decision to try to separate the markup from the logic! You can even improve it by letting ItemManager render the markup, so you can focus completely on the script logic... The only thing I notice now is that you add your CSS directly into the <body>, which might not be optimal because they should be in the <head> area. It would be even better if you use GetSimple native functions like "get_header()", "get_page_content()" and "get_footer()" to integrate your script into the CMS. It is also a better option to use "SimpleItem" objects instead of "Item" objects, because the execution time would be even faster. It is also recommended to physically resize the images, i.e. use the thumbnails and load the large images on demand. Here I have written an example how you can do it (I think it should be compatible with your script): https://gist.github.com/bigin/cb1c58b6b308ec041245bb56eeac3443 The example above contains only 3 functions that you can add to your "functions.php" file, note that your template must contain "get_header()", "get_page_content()" and "get_footer()" methods. 1. The function "getTemplate()" retrieves your markup and can be customized. It contains variables like [[URL]], [[CONTENT]] etc, which are replaced with values. 2. The function "getResizedUrl()" takes care of creating the thumbnails. 3. And the function "photobox()" contains the logic. The funny part is that the script works like a plugin, but is not really one. Try it out, take it apart, maybe you'll find something useful there. Have fun! ;-) RE: ItemManager 2.0 - Felix - 2020-05-14 Hi Bigin, First of, thanks for writing the example code on github. Splitting it up in 3 functions makes it good example code to learn better use of both ItemManager and GS. The function "getTemplate" is very interesting. I still don't grasp yet all possible api. I have read in the forum about the GS methods "get_header()", "get_page_content()", "get_footer()" but have only used so far "get_page_content()". Yes I know that css should be called in the <head> aread and the javascript just before </body> but not all picture galleries out there respect that. Some of them only seem to work with the js directly called after the gallery html. I have read about SimpleItem but not used it yet. Will update my themes with it. Also I am glad to have found and want to start using PHPThumb: https://github.com/masterexploder/PHPThumb/wiki/Basic-Usage I have seen that ItemManager automatically creates thumbnails in: /data/uploads/imanager/x.y/thumbnail/ with size 133x100 Is there a way in ItemManager to change the 133x100 values ? F. |