Jump to content

Link zur Kategorieseite


OldDaddy

Recommended Posts

Hallo Schwarmwissen,

ich möchte im Shop auf der Artikelseite in der Nähe des Warenkorb-Buttons allgemeingültige Links einbauen, welche auf die Artikelliste in der jeweiligen Kategorie verweist.

Beispiel der Artikel meineurl/kategorie1/artikelname.html von dieser Artikelseite aus möchte ich auf alle Artikel verweisen in meineurl/kategorie1/

Hat jemand einen Lösungsvorschlag oder Denkanstoss für mich, da ich mich aktuell irgendwie völlig verrenne.

Der Shop läuft unter Version 1.7.8.9

Danke schonmal im Voraus

Link to comment
Share on other sites

Dieser Code in der product.tpl an der gewünschten Stelle sollte funktionieren:

<ul class="productcats">
  {foreach from=Product::getProductCategories($product.id) item=cat}
	
		{assign var='current_cat' value=Category::getCategoryInformations(array($cat))}
		<li><a href="{$link->getCategoryLink({$cat})}" title="{$current_cat[{$cat}]['name']}">{$current_cat[{$cat}]['name']}</a></li>
	
  {/foreach}
</ul>
Edited by rictools (see edit history)
  • Like 1
Link to comment
Share on other sites

This code snippet generates an unordered list (<ul>) of product categories. It utilizes a template loop to iterate through the categories associated with a specific product. For each category, it creates a list item (<li>) containing a link (<a>) to the category page. The link is generated using a function, likely provided by a platform or framework, and includes a title attribute displaying the category name on hover.on myreceiptfy Overall, this code dynamically generates a navigable list of product categories.

Link to comment
Share on other sites

Hi rictools. Du bist klasse. Das funktioniert soweit.

Jetzt habe ich noch 2 "Probleme":

1) Wenn ein Artikel in mehreren Kategorien ist, werden jetzt alle Kategorien angezeigt. Wie müsste dann der Code lauten, wenn nur die Hauptkategorie des Artikels als Link angeziegt werden soll?

2) Ich würde gerne oberhalb des ganzen eine Textzeile haben "Weitere verfügbare Längen und Profile finden Sie unter:" Hier werden aber dann die Umlaute durch Symbole ersetzt. Wie kann man denn das lösen?

Link to comment
Share on other sites

1) Schau mal in diesen Thread, da wurde das glaube ich auch behandelt:

Wobei es ja gar nicht verkehrt ist, wenn ggf. mehrere Kategorieseiten angegeben werden. Ich habe das bei mir so eingebaut, dabei aber eine if-Abfrage eingebaut, die bestimmte Kategorien ausschließt (nach dem foreach):

{if $product_category.id_category != 2 && $product_category.id_category != 31}...{/if}

2) Die Textcodierung sollte UTF-8 sein, als Editor eignet sich z. B. Notepad++. Du kannst auch Umlaute durch z. B. &auml; für "ä" ersetzen.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

To add generic links on the product page near the add-to-cart button that point to the article list in the respective category, you can follow these steps:

Identify the Current Category: First, determine the current product's category. This can often be done by analyzing the product's URL or by fetching the category information from the product object in your shop's backend.

Generate the Link: Once you have the category identified, generate a URL that points to the category listing page. This URL structure typically follows a pattern like myurl/categoryName/ like receptify.

Modify the Product Page Template: Edit the product page template file in your theme to include the generated link near the add-to-cart button. You'll likely be editing a file that is part of your theme, often named something like product.tpl or a similar name, depending on your shop's software and version.

Ensure Dynamic Link Generation: Make sure that the link is dynamically generated based on the product's category. This might involve some backend logic to fetch the category's URL key or name and inserting it into the link's href attribute.

Since your shop is running on version 1.7.8.9, you should also check the documentation specific to your e-commerce platform (presumably PrestaShop, based on the version number) for any built-in functions or modules that could simplify this task. PrestaShop, for example, has object models and helper functions that could be used to retrieve the category information and generate the URL.

Remember, when making changes to your shop's theme or codebase, it's a good practice to test changes in a development environment first to avoid impacting your live site.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...