Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Help with meta description conditionals

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-24-2016, 02:00 PM
 
FMF FMF is offline
 

Advanced Member
  
Join Date: Apr 2010
Posts: 77
 

Default Help with meta description conditionals

Hi All,

I am trying to change my meta description code so that if I am on a product page it will just automatically use the $product.descr information. Right now it is using the site wide meta-description.

I've found the code that I need to alter, but my skills are limited so I could use some help.

The Meta Code:

Code:
{if $printable} <meta name="ROBOTS" content="NOINDEX,NOFOLLOW" /> {elseif $main eq 'wordpress'} <base href="{$catalogs.customer}/" /> <meta name="description" content="{$page_data.metadescr|truncate:"500":"...":false|escape}" /> <meta name="keywords" content="{$page_data.metakeywords|truncate:"500":"":false|escape}" /> {if $page_data.additional_meta} {foreach from=$page_data.additional_meta key=prop item=val} <meta property="{$prop}" content="{$val}" /> {/foreach} {/if} {if $main eq 'product'} <meta name="description" content="{$descr}" /> <meta name="keywords" content="{$page_data.metakeywords|truncate:"500":"":false|escape}" /> {else} {meta type='description' page_type=$meta_page_type page_id=$meta_page_id} {meta type='keywords' page_type=$meta_page_type page_id=$meta_page_id} {/if}

I need to add something like this:

Code:
{if $main eq 'products'} <meta type="description" content="{$product.descr|strip_tags:false}"> {/if}


But I am having difficulty figuring out where to logically add it into the code.

Any help?
__________________
X-Cart GoldPlus: 4.6.4
reBOOT Template
CDSEO Pro 2.0
Total Server Solutions Hosting
Reply With Quote
  #2  
Old 04-24-2016, 04:28 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Help with meta description conditionals

Agreed this is not the best behavior. We found it simpler to adjust the code in include/func/func.product.php after:

PHP Code:
.
    
$product['meta_description'] = trim($product['meta_description']);
    
$product['meta_keywords']    = trim($product['meta_keywords']); 
add:
PHP Code:
if (empty($product['meta_description']))
    
$product['meta_description'] = trim(strip_tags(func_query_first_cell("SELECT descr FROM $sql_tbl[products_lng_current] WHERE productid='$productid'"))); 
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following 2 users thank cherie for this useful post:
FMF (04-27-2016), qualiteam (04-24-2016)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:07 AM.

   

 
X-Cart forums © 2001-2020