Announcement

Collapse
No announcement yet.

PHP altering filename

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP altering filename

    I'm learning a bit of PHP and have managed to get my brand names variable and remove the spaces replacing them with dashes as per the brand image.

    I can get the result to echo and it shows correct.
    What I don't understand is how to get this echo to replace my brands variable.
    Can anyone help?


    <actinic:block php="true" >
    $sOriginal = "<actinic:variable name="Brand" />";
    $sOriginal = preg_replace('/ /', '-', $sOriginal);

    echo $sOriginal;

    </actinic:block>

    <actinic:block if="Brand%20%20%21%3d%20%22None%22" >
    <a href="http://www.stitchfactory.co.uk/acatalog/<actinic:variable name="Brand" />.html" TARGET="_blank">
    <img border="0" src="Brands\<actinic:variable name="Brand" />.gif" align="left" /> </a>
    </actinic:block>
    Clothing to make an impression.
    www.stitchfactory.co.uk

    #2
    The <a ... > line can be changed to:
    Code:
    <a href="http://www.stitchfactory.co.uk/acatalog/<actinic:block php="true" >
    	$sOriginal = '<actinic:variable name="Brand" encoding="perl" selectable="false" />';
    	$sOriginal = preg_replace('/ /', '-', $sOriginal);
    	echo $sOriginal;
    </actinic:block>.html" TARGET="_blank">
    But it could be simplified to
    Code:
    <a href="http://www.stitchfactory.co.uk/acatalog/<actinic:block php="true" >
    	echo str_replace(' ', '-', '<actinic:variable name="Brand" encoding="perl" selectable="false" />');
    </actinic:block>.html" TARGET="_blank">
    As str_replace is a lot faster than preg_replace and you're not actually using any regular expressions.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      I tried the code but couldn't see anything on the screen so changed to..

      <img border="0" src="Brands\<actinic:block php="true" >
      echo str_replace(' ', '-', '<actinic:variable name="Brand" encoding="perl" selectable="false" />');
      </actinic:block>.gif" TARGET="_blank" alt="<actinic:variable name="Brand" />">

      which gives the "Brand" image I was looking for.

      I don't understand though how to run the code combined with the .html code for it also to be a hyper-link to the brand section.
      Clothing to make an impression.
      www.stitchfactory.co.uk

      Comment


        #4
        For debugging purposes just temporarily remove all "<" from all your code - or replace it with "(". Then it will show on screen and you can see if it makes sense.

        Only you know what your URL's look like so it's up to you to match them with your variables.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment

        Working...
        X