Hi smsHH,
yes, that's a known bug with image upload field and that is why I recommend to use a file upload field instead. The file upload field have the same function as an image upload, but it is less bugged and is much quicker. Just change your image field to file upload field in admin and re-save all your items with API or manually. The field attributes of the file upload field are a little different, so you'll need to use "fullurl" instead "imagefullurl" or "title" instead "imagetitle". There's is a comparison of the field attributes, just search for "field attributes" in the description: http://get-simple.info/extend/plugin/im-...elds/1057/
The snippet you posted is OK, but it's a bit messy and could be slow if you have many items. If you want to show only a single item you don't need to loop through all the items to find what you need, the ItemManager does that already. After the init() function is executed, you can simple call getItem() function with a custom selector, here's an example:
I don't know what of field type is the "art" field in your code, probably a "slug" field, if so, you don't need to use strtolower(), because slug field value is always lower case.
The selector "active=1" work well if you use that selector a correct way, see my example bellow.
For example, if you want to get only one item by page slug you can do it as follows (I use file upload field in my example):
Have a nice day!
yes, that's a known bug with image upload field and that is why I recommend to use a file upload field instead. The file upload field have the same function as an image upload, but it is less bugged and is much quicker. Just change your image field to file upload field in admin and re-save all your items with API or manually. The field attributes of the file upload field are a little different, so you'll need to use "fullurl" instead "imagefullurl" or "title" instead "imagetitle". There's is a comparison of the field attributes, just search for "field attributes" in the description: http://get-simple.info/extend/plugin/im-...elds/1057/
The snippet you posted is OK, but it's a bit messy and could be slow if you have many items. If you want to show only a single item you don't need to loop through all the items to find what you need, the ItemManager does that already. After the init() function is executed, you can simple call getItem() function with a custom selector, here's an example:
Code:
$item = $itemClass->getItem('art=Your Art Value');
I don't know what of field type is the "art" field in your code, probably a "slug" field, if so, you don't need to use strtolower(), because slug field value is always lower case.
The selector "active=1" work well if you use that selector a correct way, see my example bellow.
For example, if you want to get only one item by page slug you can do it as follows (I use file upload field in my example):
PHP Code:
$slug = get_page_slug(false);
$manager = new IManager();
if(!$manager){die('ItemManager not installed!');}
$kategorie = $manager->getCategoryMapper()->getCategory('name=Kategorie');
if(!$kategorie){die('Category -Kategorie- does not exist!');}
$itemClass = $manager->getItemClass();
$itemClass->init($kategorie->id);
$item = $itemClass->getItem('art='.$manager->sanitizer->pageName($slug));
// If you want to get only active item, your selector could be ('art=Your Art && active=1'):
//$item = $itemClass->getItem('art='.$manager->sanitizer->pageName($slug).' && active=1');
if($item) {
$imageTitle = $manager->sanitizer->text($item->fields->image->title[0]);
$imageUrl = $manager->sanitizer->text($item->fields->image->fullurl[0]);
echo '<img alt="'.$imageTitle.'" src="'.$imageUrl.'" />';
}
Have a nice day!