This topic is locked
[SOLVED]

 Custom $customjscript on all pages

7/11/2014 5:20:25 AM
PHPRunner General questions
A
aalekizoglou author

Usually I put a custom tag like $customjscript on all pages of a project. After that I use the tag in my PHP to pass on javascript I want on the page.
Is there a brick html in PHPRunner templates that is used in every page (list,add,register,login, etc) so that I can change that? I suppose I cannot do that in header

Sergey Kornilov admin 7/11/2014

Header file should work just fine for this purpose.

A
aalekizoglou author 7/14/2014



Header file should work just fine for this purpose.


Surgey,
How should I put a {$customjscript} in my header file. I have tried it with and without <?php ... ?>
in BeforeDisplay of my form when I do
$somescript = "some script here";

$xt->assign("customjscript",$somescript);
I do not get the customjscript populated.

Sergey Kornilov admin 7/14/2014

You should not put variables like {$customjscript} in header.php. Just put any sort of PHP code you need there.

A
aalekizoglou author 7/14/2014



You should not put variables like {$customjscript} in header.php. Just put any sort of PHP code you need there.


I know. That's why header.php does not serve my request.

What I need is a {[size="2"]variable on every single page of my project, so that I can assign it whatever javascript code I wanna have.[/size]
[size="2"]For example in one page I wanna have[/size]



[size="2"]

$customjscript = "";

$customjscript .= <<<EOT

<script type="text/javascript" src="include/jquery-addons/jquery.ddslick.js"></script>

EOT;
$xt->assign("customjscript", $customjscript);


while in another

[size=2]

[/size]

[size="2"]

$customjscript = <<<EOT

<script type="text/javascript">

var registeremail = '$email';

var registerfirstname = '$firstname';

var registerlastname = '$lastname';

</script>

EOT;

$xt->assign("customjscript", $customjscript);

[/size][/size]

Sergey Kornilov admin 7/14/2014

Add ramifications to your PHP code so it serves different Javascript based on current page URL.

A
aalekizoglou author 7/15/2014



Add ramifications to your PHP code so it serves different Javascript based on current page URL.


ramifications ??

Isn't there a single brick that is included in every page? I could change that and put my tag there

Sergey Kornilov admin 7/15/2014

That single brick is the header. Place your PHP code there. Based on the current page URL output either one piece of Javascript or another. As simple as that.

A
aalekizoglou author 7/16/2014



That single brick is the header. Place your PHP code there. Based on the current page URL output either one piece of Javascript or another. As simple as that.


Sergey,
I see. Though it would be nice if I could have that functionality in BeforeDisplay of every page I want to assign $customjscript.

A
aalekizoglou author 7/17/2014



That single brick is the header. Place your PHP code there. Based on the current page URL output either one piece of Javascript or another. As simple as that.


Sergey,
on the other hand I found another solution.
On the Templates section I added on page.html a [size="2"]{$customjscript} right after the [/size][size="2"]{$header}. That was instantly put in all pages as I initially wanted. Here is what I did:[/size]



...
{BEGIN body}

{$header}

{$customjscript}

<div class="rnr-page">

<div class="rnr-top {$blockclass_top}">

<!--%%top%%-->

</div>

...