eCommerce - H1 for product name on product page, not search results?
Permalink
Ok, so I can change the core_commerce display.php file to add an h1 tag to the product name which displays nicely on a product page. Unfortunately this also adds an h1 tag to all search results, really breaking it. How can I have the h1 just on the product page?
Code below
Thanks!
Code below
<div> <?php if ($displayNameP) { ?> <h1 class="commercehead"><strong><?php echo $link_before.$product->getProductName().$link_after?></strong> <?php } ?> <?php if ($displayNameP && $displayPriceP) { ?> - <?php } ?> <?php if ($displayPriceP) { ?> <?php echo Loader::packageElement('product/price', 'core_commerce', array('product' => $product, 'displayDiscount' => $displayDiscountP)); ?> <?php } ?></h1> </div>
Thanks!
Might I suggest that you use the STYLE command instead of H1:
I'm looking for H1 so that each product page will automatically generate the H1 for search engines, rather than manually doing it. It made sense to use the product name. Thanks for the suggestion!
Or acutally, to target ONLY your product lists, don't edit the display.php at all.
Edit the block/ product_list/ view.php You'll find it here:
/packages/core_commerce/blocks/product_list/view.php
Copy this view.php file to your root C5 directory under:
/blocks/product_list/view.php
Then edit this file to your liking.
Good luck.
Edit the block/ product_list/ view.php You'll find it here:
/packages/core_commerce/blocks/product_list/view.php
Copy this view.php file to your root C5 directory under:
/blocks/product_list/view.php
Then edit this file to your liking.
Good luck.
I'm no good with PHP :) I can't find where in here I would add the <h1> tag to affect the product name?
Thank you
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); global $c; $uh = Loader::helper('urls', 'core_commerce'); $im = Loader::helper('image'); if ($options['show_search_form']) { $this->inc('view_search_form.php', array( 'c'=>$c, 'b'=>$b, 'controller'=>$controller,'block_args'=>$block_args ) ); } ?> <?php if ($options['show_products'] || $_REQUEST['search'] == '1') { ?> <?php $nh = Loader::helper('navigation'); $productList = $this->controller->getRequestedSearchResults(); $products = $productList->getPage(); $paginator = $productList->getPagination();
Viewing 15 lines of 111 lines. View entire code block.
Thank you
Jeff, any ideas? I haven't been able to figure this one out yet. I appreciate the input.
In the ecommerce version prior 2.0.3 changing the product name was easy through inline css added to productname(in product_list / view.php). Looks like you've been discussing this version here.
Current update has many changes in the code and productname attribute seems to be replaced by a variable ($pr I think). I tried to change the css of ccm-core-commerce-product-list-results but it's not defined in any of the css files (?) I searched through the whole module for it.
Can anybody shed some light on how to control/change the product name css in product and product list blocks. Not a programmer/developer so sorry if i missed something obvious.
Current update has many changes in the code and productname attribute seems to be replaced by a variable ($pr I think). I tried to change the css of ccm-core-commerce-product-list-results but it's not defined in any of the css files (?) I searched through the whole module for it.
Can anybody shed some light on how to control/change the product name css in product and product list blocks. Not a programmer/developer so sorry if i missed something obvious.
open
core_commerce/elements/product/display/properties.php
and find
<h2><?=$link_before.$product->getProductName().$link_after?></h2>
thats the title
so
<h2 class="core-commerce-product-name"><?=$link_before.$product->getProductName().$link_after?></h2>
core_commerce/elements/product/display/properties.php
and find
<h2><?=$link_before.$product->getProductName().$link_after?></h2>
thats the title
so
<h2 class="core-commerce-product-name"><?=$link_before.$product->getProductName().$link_after?></h2>
Mnkras, I only have
core_commerce/elements/product/display.php
no properties.php file
I have checked and everything is updated.
core_commerce/elements/product/display.php
no properties.php file
I have checked and everything is updated.
Thanks Mnkras but it didn't work. I replaced the code btw line 26 was this (with 'echo'):
anyway, I tried different things, also removing htis line all together. No changes. Also changed other parts just to make sure I wasn't running it from cache. All other things were updating except the bloody heading...
<h2><?php echo $link_before.$product->getProductName().$link_after?></h2>
anyway, I tried different things, also removing htis line all together. No changes. Also changed other parts just to make sure I wasn't running it from cache. All other things were updating except the bloody heading...
could you assist me in setting up the product tittle in H1?
Mnkras. thanks that works