Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ItemManager 2.0
#51
I want to show a single page of an Item.
For example: I have a store that sells phones and TVs. Those are my categories and I can already show the list of all phones or TVs on category page. What I need is detailed page of one Item, say, phone Samsung Galaxy 5 page, where I can put all the info about this particular product.

For now my code is nothing much to see. I am rendering a list of items on category page.
Code:
<ul class="item-list">
   <?php
       foreach($itemAccessor->items as $item) {
           echo '<li>'. $item->name . '</li>';
       }
   ?>
</ul>
Reply
#52
(2016-04-17, 00:57:40)nihaha Wrote:
Code:
<ul class="item-list">
   <?php
       foreach($itemAccessor->items as $item) {
           echo '<li>'. $item->name . '</li>';
       }
   ?>
</ul>

Ok. I just wanted to know how you pass your item and category data on the function that should display item details. But I see nothing in your example.

To show the data of a specific item you first have to send the "slug" or "id" of the item's category. You should also pass the item's "id" or "slug" (when you are using slug field), so your foreach loop might then look like this:

Code:
foreach($items as $item) {
   echo '<p><a href="catalog/'.$category->slug.'/?item="'.$item->get('id').'" >'.$item->name.'</a></p>';
}

On the details page you will then receive the data you send:

Code:
// the $slug could be your category slug
$slug = get_page_slug(false);
if(!empty($slug) &&  !empty($_GET['item'])) {
    $imanager = new IManager();
    // Get the category id by the slug
    $catAccessor = $imanager->getCategoryClass();
    $categoryData = $catAccessor->getCategory("slug=$slug");
    if(empty($categoryData)) die('Category Data was not found');

    // get a single item by category-ID and item-ID
    $itemsAccessor = $imanager->getItemClass();
    $itemsAccessor->limitedInit($categoryData->get('id'), (int)$_GET['item']);
    $item = $itemsAccessor->items[(int)$_GET['item']];
}
 
Now, you can use your $item object:

Code:
if(!empty($slug) &&  !empty($_GET['item'])) {
    ...

    $item = $itemsAccessor->items[(int)$_GET['item']];

    // To output item name
    echo $item->name.'<br>';

    // To output a field value
    echo $item->fields->your_field_name->value.'<br>';

    // etc
}
Reply
#53
Ok, I've got the idea, Thank you.
Reply
#54
Btw.  To make your URLs more search engine friendly see gs-front-router plugin, - really useful.
Reply
#55
Ok, thanks for the tip.
Can you, please, help me with one more thing...
I'm new to the GetSimple CMS itself and trying to understand the general picture.

So, I've made a list on items as you showed me
Code:
foreach($itemClass->items as $item) {
    echo '<p><a href="'.$categoryClass->categories[1]->slug.'/?item='.$item->fields->slug->value.'" >'.$item->fields->name->value.'</a></p>';
}

Now I can reach a page with url like this: sitename.com/catalogue/phones/?item=product-1
How should I proceed with creating a template for my product page?
Should I create a Page in admin panel first and assign my product.php (my template) to it and inside this template file call all the content of my item?
Reply
#56
Yes, it's just one of the many ways you could do it, you could create the pages catalogue/phones/ in GS admin and assign a product.php template to phones.
Or you can even use your standard template and just check whether the data is sent, then execute ItemManager's code:

if(!empty($slug) && !empty($_GET['item'])) {
...
Reply
#57
ItemManager 2.3.3 is released

Recent changes:

Slightly API modifications have been made in order to ease the use even for non-programming developers.
The ItemManager’s initialization can now be performed within templates and/or plugins as follows:

Code:
$imanager = imanager();

Some functions for getting, finding, saving and deleting items can be called now directly:
Code:
$item = $imanager->getItem('name=Category Name', 'name=Item Name');


Get single item by category id and item id
Code:
$item = $imanager->getItem(27, 5);


Get single item by category id and item name
Code:
$item = $imanager->getItem(27, 'name=My item name');


Get multiple items by category-id and item activated
Code:
$items = $imanager->getItems(27, 'active=1');


Get all items by category-id and filter them by id in descending order
Code:
$items = $imanager->getItems(27);
$filteredItems = $imanager->filter($items, 'id', 'DESC');


Fluent Interfaces
Many of the API objects in ItemManager are chainable now, using a fluent interface. This enables you to accomplish multiple operations on one line:
Code:
echo imanager()->getItemMapper()->getItem(1)->name;
Reply
#58
Hey Bigin,

Gratz on your effort for the 2.3.3. release. The lack of a very simple API was the only thing holding me back from playing with this plugin's features.
Respect.
Reply
#59
hi Tyblitz,
I'm very pleased about that, It's a more fun to working on ItemManager when large number of developer is using it.
Currently I am about to update the ItemManager's documentation, I hope it will be a bit easier to read.
Reply
#60
Hi,

first i would like to say thank you for this plugin, it's a great plugin.

But, i have a trouble with file upload field. I can't uplaod any pictures, i got a message (Error Internal server error), but i don't have any trouble with default Get Simple upload file section.

And i don't see any errors in my logs.

Get-Simple 3.3.10 / ItemManager 2.3.3
Reply
#61
Ok, it's corrected.

in imanager/upload/server/php/indes.php admin directory it's hard define. And i renamed this directory.
Reply
#62
hmmm yes, a shame, I forgot to check that file after the last update. It's been added to my todo list. thx!
Reply
#63
(2016-07-28, 01:25:19)Bigin Wrote: hmmm yes, a shame, I forgot to check that file after the last update. It's been added to my todo list. thx!

What i made :

in php/index.php

replace


Code:
require_once('../../../../../admin/inc/common.php');


by


Code:
# Check and load gsconfig
if (file_exists('../../../../../gsconfig.php')) {
   require_once '../../../../../gsconfig.php';
}

# Apply GSADMIN env
if (defined('GSADMIN')) {
   $GSADMIN = GSADMIN;
} else {
   $GSADMIN = 'admin';
}

require_once '../../../../../' . GSADMIN . '/inc/common.php';
Reply
#64
fixed on GitHub
https://github.com/bigin/ItemManager_2.0...ex.php#L13
Reply
#65
IM Extra Fields

GetSimple plugin based on ItemManager 2

IM Extra Fields is a GS plugin based on ItemManager 2.3.4 - ItemManager offers since version 2.3.4 new features, that simplify the usage the plugin in combination with GetSimple native pages. The IM-Extra-Fields plugin allows creation extra fields for native GS pages and is a kind of a mix between "I18N Custom Fields" and "Special Pages" plugins.

I have decided to remove IM Extra Fields from extend. If you are interested just load from my GitHub repo

PS:
Now, i think the version 1.0.0 of the IM Extra Fields is stable and is available for download in extend:
IM Extra Fields
Reply
#66
Hi, Bigin
First of all, i wanna congratulate you for this amazing plugin. I was looking for some time a plugin that create a product catalog o something similar but i didn't find it or at least i didn't find a proper one.
Well I was checking your demos and i wondering if you can upload one of your demos for the people, like me, who don't understand completely how to put the fields in the templates.
Reply
#67
Hi Inugami,

thx. As the categories, fields and contents could have quite different design, depending on your needs and on your created properties, there is not really anything to download available. And as I do not know how your catalog is structured (categories, fields, etc) and how you want to bring it to display, so I am not really able to help you with it. ItemManager is not a content- or HTML-markup generator! Some want to build a catalog with an image and a text field or multiple images + 10 various fields, others prefer just a catalog with text only or something else. As ItemManager does not force you to use any kind of specific content or markup, so it's not possible to create an example to all the peoples and cases.

A step-by-step (example) instructions how creating a simple catalog with dummy categories, you can see on my website at http://ehret-studio.com/lab/2015/mai/tut...emmanager/
But this is only one of thousands different possibilities for implementing a catalog.
Maybe it looks a little confusing, but do not be misled by the large amounts of code. By and large, there are only 3 files you actually need for a simple catalog:

products.php
catalog.php
functions.php

You can put all that files in the same theme folder, for example. If the theme directory is present, please do not overwrite the existing files with the same name, just rename it or simple add the code to that file.

All the other infos, what categories, fields and GetSimple pages you need, you will find here:
http://ehret-studio.com/lab/2015/mai/tut...emmanager/

Try it, if something did not work or If you have any questions, then let me know I would be glad to help you.
Reply
#68
So, how do i get those "extra" images to show as thumnails?.
I made category Fruits and made 5 items and each item has 4 images, but only one "large" image shows in page.
Reply
#69
Are you talking about "IM Extra Fields" plugin or ItemManager? Which method you use to access the images field values, show me your snippet pls.
Reply
#70
Here's a function which creates the thumbnails at any size you like on the fly. Just copy and paste the code in your functions.php: https://bigin.github.io/ghpages/resizeimage/

You can call functions as follows:

Code:
echo getResized($item->fields->images, 0, 150, 0);

Parameter descriptions you can find at the link above.
Reply
#71
I cant get the thumbnail thing to work, so nevermind that one, but i have new one Big Grin
when i click item in products page it goes to front page, what im doing wrong?.
Im playing with GS in here
Reply
#72
(2016-08-31, 02:41:46)Riianna Wrote: I cant get the thumbnail thing to work, so nevermind that one, but i have new one Big Grin
when i click item in products page it goes to front page, what im doing wrong?.
Im playing with GS in here

The getResized() function works 100%, so you done something wrong.
Your routing look pretty different, are you trying to use my example catalog? Are you using fancy URLs? If not, then the code needs changed in several functions.
Reply
#73
(2016-08-31, 03:06:03)Bigin Wrote:
(2016-08-31, 02:41:46)Riianna Wrote: I cant get the thumbnail thing to work, so nevermind that one, but i have new one Big Grin
when i click item in products page it goes to front page, what im doing wrong?.
Im playing with GS in here

The getResized() function works 100%, so you done something wrong.
Your routing look pretty different, are you trying to use my example catalog? Are you using fancy URLs? If not, then the code needs changed in several functions.

It was that testing place server which causes problems ( mod rewrite, htaccess etc etc ).
In my "real" site everything works ok, no problems Big Grin.
Reply
#74

  1. If, when IM Extra fields is activated, I save a page, I get a HTTP ERROR 500.
  2. Version is 1.0, but gives a link to download "new version" 1.0.0
ItemManager 2: 

1. On plugins page (GS-admin) links to Item Manager 0.7: http://get-simple.info/extend/plugin/item-manager/669/

Instead of: http://get-simple.info/extend/plugin/itemmanager/936/

2. When I upload images in ItemManager 2 I get the following error: Failed to resize image (thumbnail)
Reply
#75
Hi, thx for the info

What PHP version do you run?

Have you tried to delete "imanager" directory and imanager.php file under plugins, then reinstall IM?
Reply




Users browsing this thread: 5 Guest(s)