This topic is locked

Major Bug : Custom smarty code in the HTML View in the Visual Editor

3/11/2008 3:00:50 PM
PHPRunner General questions
S
spintz author

The Visual Editor updates code placed between {php}{/php} blocks, and it causes the smarty templates to go haywire, because PHPR keeps altering my custom PHP code, thinking it's HTML for the editor or something.
I have code like this -

{php}

global $smarty;

$val = $smarty->get_template_vars('value_sowrefid' );

$sowrefdisplay = getParagraphTitles( $val );

echo "<TEXTAREA id=sowrefid style='WIDTH: 500px; HEIGHT: 150px;' value='$sowrefdisplay'></TEXTAREA>";

{/php}


and PHPR keeps changing it to things like -

{php}global $smarty; $val

= $smarty-&gt;get_template_vars('value_sowrefid' ); $sowrefdisplay

= getParagraphTitles( $val ); echo "<TEXTAREA id=sowrefid style="WIDTH: 500px; HEIGHT: 150px;"

value="$sowrefdisplay"></TEXTAREA>";

{/php}


It's changing the - > - to &gt; and it's changing my single quotes to double quotes.
Also, PHPR does not properly handle the { } smarty comments and displays this raw text in the GUI part of the Visual Editor, which is a bit of a pain.
In general, PHPR needs to be more aware of hand added smarty code in the HTML view.

S
spintz author 3/11/2008

As a workaround, I can setup my code inside the {php}{/php} block, then go directly the Build or Next. If I ever go to the WYSIWYG Visual Editor for that page, then PHPR reformats that code for me, and I have to change it back before building my app. Please, please fix this soon! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=26864&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 3/11/2008

If you need to insert PHP code into the template use Insert PHP code snippet button in Visual Editor.

S
spintz author 3/12/2008

That's a sufficient workaround, but not, IMO, a solution. The {php}{/php} tag is supported by smarty, so it should be properly handled in the HTML editor.
Also, with this method, is there some way to add a Global event, for all Tables? For multiple tables that are sharing the same PHP code, I am manually editting commonfunctions.php, adding my php function that does what I want, then setting up an event for each table type and have the event for that table type, call the function I declared in commonfunctions.php. I've discovered that a events for a table type are stored in the same file, so I can declare a single event per table, then call if from all functional pages for that table. For example, I declare a PHP code snippet with a function called requests_insertSOW from the Edit page for my requests table. Then, in the add page, I can just call that function, I don't have to re-declare a function. That's makes it a little better, but it becomes confusing, as the Add page is calling a function declared in the Edit page, and on the Events tab, they are show in different sections. It'd be nice to have multiple scopes for function - ( Global, Table, Page ).

J
Jane 3/13/2008

Hi,
PHPRunner uses pared-down smarty.

To add some PHP code use custom events (Insert PHP code snippet option).
To add global events use one of the global event, for example Menu page: before process event.

Here is a sample:

//you code for Menu page: before process event

...

}//end of menu event
//your function here

function YourCustomFunction()

{

//your code

...

S
spintz author 3/13/2008

To add global events use one of the global event, for example Menu page: before process event.


That helps, however I have a simple request. Could CommonFunctions be included before Events.php? I modify CommonFunctions to include some of my custom functions, but with Events.php being included first, the functions are undefined.