Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32
  1. #21
    Join Date
    May 2010
    Location
    WA State
    Posts
    1,678
    Plugin Contributions
    3

    Default Re: Replacing a text string on a page

    Would it be possible to create an SQL patch that accomplishes this? Or, am I not understanding how category and product titles are stored?

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

    Default Re: Replacing a text string on a page

    The OP wants to use only one database for all of these sites, and output keywords specific to each site.

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

    Default Re: Replacing a text string on a page

    Ah, okay. I missed that.

  4. #24
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    Stuck on this bit on the product_listing.php module



    } else {
    $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['product_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listi ng->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

    Bit in bold is the string that brings up the product name, but everything ive tried has brought it up blank.

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

    Default Re: Replacing a text string on a page

    You have a typo there - the field is products_name.

    $listing->fields['products_name']


    You haven't said exactly what happened when you tried the function. If you want your version to be more maintainable, you really need to develop a cleaner method than inserting a bunch of individualized PHP into every file you want to affect.

  6. #26
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default

    Quote Originally Posted by gjh42 View Post
    You have a typo there - the field is products_name.

    $listing->fields['products_name']


    You haven't said exactly what happened when you tried the function. If you want your version to be more maintainable, you really need to develop a cleaner method than inserting a bunch of individualized PHP into every file you want to affect.
    Yes sorry, ignore the Typo. It just came out blank where the text should have been. I'm not really concerned about the maintenance. I have a note of the files changed and the code is inserted at the top of each php file. I'd just like to get it working first then look at a way of doing a global function.
    Posted via Mobile Device

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

    Default Re: Replacing a text string on a page

    A str_replace() example from the PHP manual:
    PHP Code:
    $phrase  "You should eat fruits, vegetables, and fiber every day.";
    $healthy = array("fruits""vegetables""fiber");
    $yummy   = array("pizza""beer""ice cream");

    $newphrase str_replace($healthy$yummy$phrase);
    // Provides: You should eat pizza, beer, and ice cream every day 
    So the function as I posted ought to work the same way. What could be different in it or its context? (Single/double quotes don't count.)

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

    Default Re: Replacing a text string on a page

    Right, I didnt continue with this, but I have another issue Im trying to get around.

    I know that you cannot mark attributes temporarily out of stock, you have to delete them, and re-add them, or replace one with one that says 'out of stock' in the title of the attribute etc..

    Now what about instead of all that, you mark the attribute display only so it can't be checked out, put a price factor of say +£999 to it, but then use my script I had at the beginning of this thread to replace the string '£999' with 'OUT OF STOCK.

    This is the script below but I just can't seem to get it to hit the right element. Ive tried elements such as form, input, select, attrib-12 (which is what my css is telling me) but none of them work..



    <script language="javascript" type="text/javascript">

    function replaceWord(control, oldWord, newWord) {

    var pageElement = document.getElementById(control);

    oldWord = new RegExp(oldWord, "g");

    if (pageElement.value)

    pageElement.value = pageElement.value.replace(oldWord, newWord);

    else

    pageElement.innerHTML = pageElement.innerHTML.replace(oldWord, newWord);

    }

    </script>


    <div id="page">


    <body onload="replaceWord('FORM', '+£999.00', 'Out Of Stock')" />

  9. #29
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

  10. #30
    Join Date
    Nov 2009
    Location
    UK
    Posts
    1,090
    Plugin Contributions
    0

    Default Re: Replacing a text string on a page

    So Ive come back to this original thought, as on further thinking it really does have good uses.

    Im fine on static titles, like category titles on a listing, or product titles and description on a product page, but when there is a listing with more than one product title or category title on a page (such as categories sidebox or a category listing lots of products, I get stuck.

    If I do what ive been doing so far, I get one category in the side box to change its title, but then all the others vanish, like wise, I can get one product in a listing to change, and all the others vanish.

    I assume because Im modifiying an array, and not a fixed string.

    For example, in tpl_columnar display... I had a listing of 157 products, but this makes only one appear with the correct name, and the other 156 vanish off the page. Any ideas?



    <?php

    // The text string
    $list_box_contents2[$row][$col] = $list_box_contents[$row][$col];

    // The word we want to replace
    $oldWordprodtitle = "oldword";

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

    // Run through the text and replaces all occurrences of $oldText
    $list_box_contents2[$row][$col] = str_replace($oldWordprodtitle , $newWordprodtitle , $list_box_contents2[$row][$col]);

    ?>


    <?php
    /**
    * Common Template - tpl_columnar_display.php
    *
    * This file is used for generating tabular output where needed, based on the supplied array of table-cell contents.
    *
    * @package templateSystem
    * @copyright Copyright 2003-2006 Zen Cart Development Team
    * @copyright Portions Copyright 2003 osCommerce
    * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
    * @version $Id: tpl_columnar_display.php 3157 2006-03-10 23:24:22Z drbyte $
    */

    ?>
    <?php
    if ($title) {
    ?>
    <?php echo $title; ?>
    <?php
    }
    ?>
    <?php
    if (is_array($list_box_contents) > 0 ) {
    for($row=0;$row<sizeof($list_box_contents);$row++) {
    $params = "";
    //if (isset($list_box_contents[$row]['params'])) $params .= ' ' . $list_box_contents[$row]['params'];
    ?>

    <?php
    for($col=0;$col<sizeof($list_box_contents[$row]);$col++) {
    $r_params = "";
    if (isset($list_box_contents[$row][$col]['params'])) $r_params .= ' ' . (string)$list_box_contents[$row][$col]['params'];
    if (isset($list_box_contents[$row][$col]['text'])) {
    ?>
    <?php echo '<div' . $r_params . '>' . $list_box_contents2[$row][$col]['text'] . '</div>' . "\n"; ?>
    <?php
    }
    }
    ?>
    <br class="clearBoth" />
    <?php
    }
    }
    ?>

 

 
Page 3 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