0

I am fairly new to EE so please bare with me. I have an issue where I want to use addslashes() on a template tag that is in an array.

$product_array["{ProductEntryID}"][] = array(
    'CustomizationNotes' => "{CustomizationNotes}",
);

I've used two different plugins with success on my local development environment Format Characters and PHPStringFun. However when I attempt to use them on the production site nothing is output.

Not sure where to go from here any help will be appreciated.

Thanks,
Dan

2
  • Can you, please, update your question with more details on what you're trying to do? – Sobral May 18 '15 at 21:44
  • Are you trying to do this in a template? Is PHP Turned on with PHP Parsing set to after? As Robson states, need more information otherwise we're just guessing at what you're trying to do. – Peter Lewis May 19 '15 at 11:10
0

This smacks of Parse order, as Robson and Peter suggest.

if that piece of PHP code is on a template somewhere, I van only assume you want the tags filled in BEFORE the php is executed, therefor set your template to PHP On on Output. You can also add the addslashes into your php array creation.

By example, first lets echo out the array so we can see what happens when :

<?php 
$product_array["{ProductEntryID}"][] = array(
  'CustomizationNotes' => addslashes("{CustomizationNotes}"),
);
print "<pre>".print_r($product_array,1)."</pre>";
?>
<span>I am not a number, I am a free span!</span>

assuming {ProductEntryID} evaluates to '10' and {CustomizationNotes} evaluates to "Don't use apostrophies" then, with PHP on Outout the first thing to happen is the tags are parsed, so your template becomes :

<?php
$product_array["10"][] = array(
  'CustomizationNotes' => addslashes("Don't use apostrophies"),
);
print "<pre>".print_r($product_array,1)."</pre>";
?>
<span>I am not a number, I am a free span!</span>

And neareer the end the php is evaluated so the source you end up with is :

<pre>Array\n
(\n
    [10] => Array\n
        (\n
            [0] => Array\n
                (\n
                    [CustomizationNotes] => Don\'t use apostrophies\n
                )\n
\n
    )\n
\n
)\n
</pre>
<span>I am not a number, I am a free span!</span>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.