Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32
  1. #11
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    Quote Originally Posted by gjh42 View Post
    So descriptions won't need to be changed? How about meta data stored in the db? Will any of that have "body con" in it?

    Yes, running a script on the set of language define files in maybe Notepad++ or something should be effective there. Adding the transform function to the product/category name output locations ought to be doable; you just need to get all locations like shopping cart, checkout and e-mail sending files.
    If you are going to do the same thing for more than one extra site, I would make the function generic and define the replacement string array in a constant which you could redefine for each new site without touching the embedded switchers.
    Ive done the product descriptions too now... :)

    I need some help on the product listings and the category sideboxes, new and featured etc., can't seem to get the string replacements to work, any tips?

    This could be a really good mod for making extra sales and for further SEO.

  2. #12
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    Quote Originally Posted by gjh42 View Post
    Good proof of concept. Now to extract it into a function so you only need to change
    PHP Code:
    <!--bof Product Name-->
    <h1 id="productName" class="productGeneral"><?php echo $products_name?></h1>
    <!--eof Product Name-->
    to
    PHP Code:
    <!--bof Modified Product Name-->
    <h1 id="productName" class="productGeneral"><?php echo text_swap($products_name); ?></h1>
    <!--eof Modified Product Name-->
    In /includes/functions/extra_functions/text_swap_functions.php
    PHP Code:
    <?php
    // The text string
    //$newprodname = $products_name;

    function text_swap($text) {
      
    $old = array('Body Con''body con');
      
    $new = array('Going Out''going out');
      
    // Run through the text and replace all occurrences of $oldText
      
    $newtext str_replace($old $new $text);
      return 
    $newtext;
    }
    ?>
    I made the extra file and put it in the extra_functions file and changed the code in tpl_prod_display etc but it didnt seem to work ?

  3. #13
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    How do I mod using my code a line like this below in the product listings...

    <h1 id="productListHeading"><?php echo $breadcrumb->last(); ?></h1>

  4. #14
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Replacing a text string on a page

    Post an example of the original code and your replacement attempt for areas where it is not working for you.

    and changed the code in tpl_prod_display etc but it didnt seem to work ?
    What did you use in tpl_product_info_display.php?

  5. #15
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    Quote Originally Posted by gjh42 View Post
    Post an example of the original code and your replacement attempt for areas where it is not working for you.

    What did you use in tpl_product_info_display.php?

    For the product listing...tpl_index_product_list.php


    Previously only this...

    <h1 id="productListHeading"><?php echo $breadcrumb->last(); ?></h1>


    Which I changed to this..

    <?php

    // The text string
    $breadcrumb2 = $breadcrumb;

    // The word we want to replace
    $oldWord = "word1";

    // The new word we want in place of the old one
    $newWord = "word2";

    // Run through the text and replaces all occurrences of $oldText
    $breadcrumb2 = str_replace($oldWord , $newWord , $breadcrumb2);



    ?>

    <h1 id="productListHeading"><?php echo $breadcrumb2->last(); ?></h1>



    ..and for tpl_product_info_display, the code you posted..

    <!--bof Modified Product Name-->
    <h1 id="productName" class="productGeneral"><?php echo text_swap($products_name); ?></h1>
    <!--eof Modified Product Name-->

  6. #16
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Replacing a text string on a page

    See http://php.net/manual/en/function.str-replace.php for info on the str-replace() function.


    So did the product name return the original unchanged, or what?

  7. #17
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Replacing a text string on a page

    <?php echo $breadcrumb->last(); ?></h1>


    Which I changed to this..

    <?php

    // The text string
    $breadcrumb2 = $breadcrumb;
    $breadcrumb is not the same as $breadcrumb->last().

  8. #18
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    Quote Originally Posted by gjh42 View Post
    $breadcrumb is not the same as $breadcrumb->last().
    You're right, and Ive fixed it now :)

  9. #19
    Join Date
    May 2010
    Location
    WA State
    Posts
    1,678
    Plugin Contributions
    3

    Default Re: Replacing a text string on a page

    Doesn't this approach add quite a bit of overhead?

  10. #20
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Replacing a text string on a page

    If done efficiently, I wouldn't think it would add more overhead than many other mods.

    Obviously the piecemeal coding approach will require an immense amount of maintenance for more than one extra site, or version upgrades.

 

 
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Replacing Text of Order Status
    By judah in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 2 Aug 2010, 04:40 PM
  2. How to find a text string
    By thomasw98 in forum General Questions
    Replies: 11
    Last Post: 2 Mar 2010, 10:05 PM
  3. Replacing category text with images
    By d'Anjou in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 8 Apr 2008, 10:45 AM
  4. “add to cart:” text string
    By gsh in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Oct 2006, 07:20 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR