Page 1 of 3 123 LastLast
Results 1 to 10 of 28
  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Need help calling variables

    Hi everyone,

    I am currently working on some code that will add
    <meta name="ROBOTS" content="NOINDEX,FOLLOW">

    on linked product pages.

    in the html_header.php file I have added:

    PHP Code:
    <?php
    include('includes/meta_noindex.php');
    ?>
    where meta_noindex.php is:

    PHP Code:
    $check_linked mysql_query('SELECT master_categories_id from products WHERE products_id = '.$prod_id.'');
    $check_result_row mysql_fetch_row($check_linked);
    $catid $check_result_row[0];

    if ( 
    $catid == $current_category_id ) {
    } else {
    $meta '<meta name="ROBOTS" content="NOINDEX,FOLLOW">';
    echo 
    $meta;

    only problem is that having the code in the html_header there is no reference to the variables:
    $prod_id
    $current_category_id

    Can anyone advise what I could do to get this to work??

    Cheers
    Phil

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Need help calling variables..

    Zen-Venom Get Bitten

  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need help calling variables..

    Quote Originally Posted by kobra View Post
    I did, thats how I knew the variable was $prod_id ! I need to know how my code can know the same $prod_id value that the tpl_product_info_display.php outputs...

    ?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    You could use the built-in functionality for $robotsNoIndex by putting your code into the end of init_add_crumbs.php and reworking it to set $robotsNoIndex under the conditions you desire.

    There are other discussions for handling canonical matters also discussed elsewhere on the forum.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    Quote Originally Posted by DrByte View Post
    You could use the built-in functionality for $robotsNoIndex by putting your code into the end of init_add_crumbs.php and reworking it to set $robotsNoIndex under the conditions you desire.

    There are other discussions for handling canonical matters also discussed elsewhere on the forum.
    Thanks BrByte,

    Any chance of a bit of guidance with the init_add_crumbs.php file?

    I tried my code in the bottom and also inside the if (isset($_GET['products_id'])) { part, but neither had the desired affect.

    My code has the correct logic, it compares the current category with the master and I set it to set the $robotsNoIndex, but it was doing this regardless for some reason?

    Phil
    Last edited by philip937; 17 Mar 2010 at 08:07 PM.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    Actually, I take part of that back. I'd recommend just adding the following to the bottom of your init_category_path.php file:
    Code:
    // set noindex, nofollow on linked products
    if ($current_category_id > 0 && $current_category_id != zen_get_products_category_id($_GET['products_id']) ) $robotsNoIndex = TRUE;
    (replacing the line with just ?> on it, if it exists, or just adding to the end of the file if the ?> doesn't exist.)
    https://www.zen-cart.com/tutorials/i...hp?article=313
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    Quote Originally Posted by DrByte View Post
    Actually, I take part of that back. I'd recommend just adding the following to the bottom of your init_category_path.php file:
    Code:
    // set noindex, nofollow on linked products
    if ($current_category_id > 0 && $current_category_id != zen_get_products_category_id($_GET['products_id']) ) $robotsNoIndex = TRUE;
    (replacing the line with just ?> on it, if it exists, or just adding to the end of the file if the ?> doesn't exist.)
    https://www.zen-cart.com/tutorials/i...hp?article=313
    DrByte,

    Thanks I almost got this working I think, however your suggestion seems to have 2 issues I can see so far (assuming I followed your instructions correctly?)

    the noindex seemed to be included in the product in the master category and not on the linked the opposite to the desired effect,

    also after adding it i noticed its adding the noindex to tag to the category pages too :o(

    here is what I did, perhaps you might point out if I have done it wrong?

    so the edit to init_category_path.php file looks like this:

    Code:
    if ($current_category_id > 0 && $current_category_id != zen_get_products_category_id($_GET['products_id']) ) $robotsNoIndex = TRUE;
    I also tried without the closing ?> tag, same result

  8. #8
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    Maybe try this instead of what I posted earlier?
    Code:
    if ($current_page != 'index' && isset($_GET['products_id']) && $current_category_id > 0 && $current_category_id != zen_get_products_category_id($_GET['products_id']) ) $robotsNoIndex = TRUE;
    Again, there are other discussions for more focused canonical handling already kicking around the forum.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    Thats works perfect but its still does the opposite i.e sets

    no index no follow on the master category and not the linked rather than the other way around??

    I even went into my category link manager to check that the master cat that it should have been was actually set right and it was...

    I'm trying to work out how your code is working? my original one compared the current category id with the master for the current product, is this how yours is working to?

    I tried removing the ! as I thought it might reverse the logic but that just set noindex on both.

    This is so close...

    I have search around the forums and can't find any similar topics.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Need help calling variables - trying to set up my own canonical URL handling

    I'm not sure why you're having any problem with it, since zen_get_products_category_id gives you the master, and $current gives you the current one, and it's already comparing those for mismatch.

    This tests fine for me:
    Code:
    //Robots no-index on product pages not using master_categories_id:
    if ($current_page != 'index' && isset($_GET['products_id']) && $current_category_id > 0 && $current_category_id != zen_get_products_category_id($_GET['products_id']) ) $robotsNoIndex = TRUE;
    Although, it only deals with product pages, and not category pages.

    However, as I've eluded to before, I'd recommend a different approach altogether: proper canonical handling.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Need help with a couple of variables
    By BushyTea in forum General Questions
    Replies: 2
    Last Post: 12 Mar 2010, 03:36 AM
  2. Help Calling JQuery?!
    By tjohnson13 in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 9 Dec 2009, 06:24 PM
  3. Need a debug tool to read variables
    By ronlee67 in forum General Questions
    Replies: 4
    Last Post: 1 Jun 2009, 04:11 AM
  4. Need User Tracking To Help Display Variables
    By bumba000 in forum General Questions
    Replies: 0
    Last Post: 5 Jan 2008, 08:39 PM
  5. Replies: 8
    Last Post: 26 Apr 2007, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg