Automatic category images in XTCommerce
Not everyone who uses a XTC system has the time to set a category image for each category – just as if you have a quiet complex category structure.
Apart from that the native XTC category image function has a further problem: The images have to be uploaded for each category. What next if you used a product image for a category and the product later possibly does’nt exist in this category anymore?
That’s why i prefer the automatic output of category images. Where do this images come from? They are product images from a product within the category.
While it’s quiet complicated to extend XTC with functions like these there is another relatively comfortable way: Through Smarty plugins.
The well documented and flexible parsing engine allows to use different plugins and to extend XTC without hacking any core files.
How does it work?
Step 1/2 – install the plugin
Download the Smarty plugin here and extract the file to the directory [XTC-Wurzelverzeichnis]/includes/classes/Smarty_2.6.14/plugins/ on your server.
Schritt 2/2 – Customise your template
Open the file
[XTC-root directory]/templates/[Your Template]/module/categorie_listing/categorie_listing.html
find this line
and comment it out. (Simply insert {* before and *} after)
After this line insert:
and save the file.
Ready
The attribute ready stands for the automatic output. It’s your choice to set it to true to output the image at random or to false to output first found image.
Attention: This script searches the database recursively for product images. So if you have a large amount of nested sub categorys without product images within you should not use this script for perfomance reasons.




December 14th, 2008 at 16:30
Ist auch auch möglich, in der Kategorie-Navigation vor jeden Navi-Punkt ein anderes Bild anzuzeigen?
December 15th, 2008 at 3:22
Falls du die Kategorie-Navi in der Box meinst, geht das nicht so einfach, weil der Inhalt der Kategorie-Box aus einer PHP-Datei raus erstellt wird.
Diese PHP-Datei liegt aber auch im Template-Verzeichnis (templates/dein_template/source/inc/xtc_show_category.inc.php). Die kannst du ja entsprechend anpassen und die Funktion aus dem Smarty-Plugin benutzen oder sie halt so basteln, dass die Navi auch über Smarty gerendert wird.
Wir können dir dabei gerne helfen.
Cheers
January 19th, 2009 at 13:01
feine sache!
ich möchte aber bei einigen kategorien selber bestimmen, welche bilder da reinkommen und die auch ganz normal über den admin hochladen. die anderen kategorien möchte ich mit den passenden produktbildern aus dem ordner thumbnails befüllen.
geht das? :-/
besten gruss
christian
January 20th, 2009 at 1:01
Jo das geht. Kommentiere dazu nicht wie beschrieben diese Zeile:
<a href="{$module_data.CATEGORIES_LINK}" ><img src="{$module_data.CATEGORIES_IMAGE}" alt="{$module_data.CATEGORIES_NAME}" /></a>{/if}
aus, sondern ändere das {/if} in {else}, füge danach wie beschrieben den neuen Code ein und schreib direkt danach {/if} ein.
—-
If you want to set category images for some categorys and let the others be chosen by this script you can manage this like that:
{else}
<a href="{$module_data.CATEGORIES_LINK}"><img src="{$module_data.CATEGORIES_LINK|auto_category_image:true}" alt="" /></a>
{/if}
January 20th, 2009 at 2:00
Es gab in dem Skript bisher Probleme mit SEF-URL’s. Dieser Bug ist jetzt gefixt und der Download aktualisiert.
—
There was a problem with SEF URL’s. This bug is now fixed and the download upon is updated.
January 28th, 2009 at 12:16
klasse skkript. spart jede menge arbeit! danke sagt
der
christian
February 15th, 2009 at 15:50
das Script funktioniert leider nicht bei aktivierung des Moduls Direct URL von http://www.bluegate.at.
Es werden einfach irgendwelche Bilder aus dem Shop genommen nicht jedoch die aus der korrekten Kategorie.
Nach der Deaktivierung geht alles einwandfrei.
February 18th, 2009 at 15:30
Das liegt daran, dass die Kategorie-ID’s aus den Links ausgelesen werden. Ist die Kategorie-ID, wie durch das Bluegate-SEF-Modul, nicht direkt im Link enthalten, erkennt das Plugin diese natürlich nicht und gibt Bilder für die Kategorie 0 aus.
In so einem Fall ist die schnellste Lösung, die Kategorie-ID an’s Template zu übergeben. (includes/modules/default.php::118). Und zwar so:
‘CATEGORIES_ID’ => ”c_’.$categories['categories_id'].’_’
Im Template die automatischen Bilder dann so erzeugen:
{$module_data.CATEGORIES_ID|auto_category_image:true}
March 23rd, 2009 at 15:55
hallo metti,
kann es sein das in der
‘CATEGORIES_ID’ => ”c_’.$categories['categories_id'].’_’
ein Fehler ist, denn ich bekomm immer eine fehlermeldung
johnny
March 23rd, 2009 at 16:12
Ja. Die Anführungszeichen hauen nicht hin. Es muss dann so aussehen:
'CATEGORIES_NAME' => $categories['categories_name'],
'CATEGORIES_IMAGE' => $image,
'CATEGORIES_LINK' => xtc_href_link(FILENAME_DEFAULT, $cPath_new),
'CATEGORIES_DESCRIPTION' => $categories['categories_description'],
'CATEGORIES_ID' => 'c_'.$categories['categories_id'].'_'
);
April 1st, 2009 at 14:36
Hallo,
wie richtet man das Script ein damit es auch mit den SEO Urls von Shopstat funktioniert?
Die Links sehen so aus: http://www.domain.de/Kategorie/Unterkategorie:::723_606.html
Es werden aber immer falsche Bilder verwendet.
Grüße
Andreas
June 7th, 2009 at 23:42
Hi,
nutze bisher keine SEO-URL.
Habe aber leider immernoch das Problem das die Bilder aus der Cat 0 gezogen werden, obwohl ich in der default.php “‘CATEGORIES_ID’ => ‘c_’.$categories['categories_id'].’_'” nachgepflegt habe und in der listing.html ID statt LINK nutze.
Gibt es da eventuell etwas woran es noch liegen kann?
Gruß,
Benny
June 8th, 2009 at 0:03
Ok Problem gefunden ^^
FALSCH!!!:
‘CATEGORIES_ID’ => ‘c_’.$categories['categories_id'].’_’
RICHTIG!!!:
‘CATEGORIES_ID’ => ‘c’.$categories['categories_id'].’_’
Bei mir (Jung/Gestalten XTC-Version) funktioniert es dann.
Gruß Benny
June 8th, 2009 at 0:39
Hier Benny nochmal XD
Hab da nochmal die Frage, wenn eine Cat aktuell keine Produkte erhält, das dann ein hinterlegtes Bild verwendet wird?
Oder allgemein gesagt, wenn kein Bild gefunden wird, dann nehme das Hinterlegte Bild?
Wäre sehr dankbar für eine Antwort.
June 8th, 2009 at 10:22
Naja – meistens findet das Skript ja trotzdem Bilder. Du kannst das Bild auf jeden Fall erstmal in eine Smarty-Variable schreiben:
Dann kannst du sie mit Smarty untersuchen (Mit IF)
Sollte das nicht ausreichen, bleibt es dir ja unbenommen, die Funktion in modifier.auto_category_image.php deinen Wünschen entsprechend anzupassen.
Gruß,
Metti
January 31st, 2010 at 19:47
Habe nach Anpassung der default.php in Zeile 18 durch überschreiben mit:
—–
$categories_content[]=array(’CATEGORIES_NAME’ => $categories['categories_name'],’CATEGORIES_IMAGE’ => $image,
‘CATEGORIES_LINK’ => xtc_href_link(FILENAME_DEFAULT, $cPath_new),’CATEGORIES_DESCRIPTION’ => $categories['categories_description'],
‘CATEGORIES_ID’ => ‘c_’.$categories['categories_id'].’_');
—–
sowie nach Änderung der categorie_listing.html
—
{if $module_data.CATEGORIES_IMAGE}
{else}
{/if}
—
leider immer noch das Problem, dass nur Bilder der Kategorie 0 angezeigt werden. Wie kann ich das Problem lösen, bzw. was habe ich falsch gemacht????
(ich benutze SEO URL Einstellungen)
Gruss
January 31st, 2010 at 19:49
Hi,
meine natürlich (includes/modules/default.php::Zeile 118).
Gruss
February 1st, 2010 at 20:26
Hallo- wäre schön, wenn mir Jeman helfen könnte…..
Gruss
March 18th, 2010 at 0:21
Hallo zusammen!
Scheint ein nettes Plug-in zu sein, nur leider bring ich’s nicht zum laufen!
In der default.php hab ich jetzt stehen:
‘CATEGORIES_DESCRIPTION’ => $categories['categories_description'],
‘CATEGORIES_ID’ => ‘c’.$categories['categories_id'].’_’);
Und in der categorie_listing.html steht:
Also genau so, wie’s oben beschrieben wird! Und trotzdem funkt’s leider nicht!
Eine Idee, wpran das liegen könnte?
Vielen Dank schon mal im Voraus!
Beste Grüße
Kello
March 18th, 2010 at 0:22
ups – zum reinkopieren vergessen
categorie_listing.html :
March 18th, 2010 at 0:23
ah, ok -liegt am html-code – sorry
hier ohne html:
src={$module_data.CATEGORIES_ID|auto_category_image:true}
May 22nd, 2010 at 12:39
Ich hatte jetzt lange an der Geschichte gessen, weil das Teil in meinem xtc wunderbar funktioniert, aber bei der XT-modified Version nicht wollte.
Kategorien übergibt die default.php bei mir trotz Änderung wie hier beschrieben, leider nicht. Keine Ahnung, worna das liegt.
Aber eigentlich geht es ganz einfach!
Man muss die Smarty-Class nur anpassen, dass diese wieder richtig abfragt.
In dem Fall der Urls in dieser Form:
http://www.magnetpinnwand.de/Magnete:::4.html
sehen die Links dann so aus:
http://www.magnetpinnwand.de/Magnete/Magnet-Sets:::4_9.html
Also muss das Script nur nach dem Unterstrich suchen und nicht nach dem “c_”
Wie man das nun aber löst, wenn die Kategorietitel Unterstriche enthalten….
Aber ein Ansatz ist das auf jeden Fall.
June 30th, 2010 at 19:48
[...] guter Artikel inklusive Smarty-Modifier-Plugin dazu, wie eine zufällige Produktabbildung automatisch als Kategorieabbildung benutzt werden kann, finden Sie bei [...]
July 24th, 2010 at 21:02
Very rarely I can see cool theme for wordpress. There are very nice themes, but very complicated to set up. I have installed recent versions of Designora, Businezz, Jarrah, Traction, also I have tried also BAsense – simple, but made for adsense. Not very often we can find something cool but good in settings.