This topic is locked

accessing datafield in the header

7/2/2010 10:17:06 AM
PHPRunner General questions
M
mdorren author

Hi,

I'm trying to use a keyfield in my view header to process a j@v@script if statement:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML {$html_attrs}><HEAD><TITLE>PublicCMS</TITLE>

<?php

$varcms = $data["cms_id"]

?>

<script type=text/javascript>
js_cms_id = <?php echo $varcms; ?>

document.write(js_cms_id);
</SCRIPT>



<META name=GENERATOR content="MSHTML 8.00.7600.16588"></HEAD>
...In my test, I can't seem to get the php variable passed to my script variable. I'm sure this must be done quite often, but I can't seem to do a search in the forum on the word J@V@script.
Ideas?

M
mdorren author 7/2/2010



Hi,

I'm trying to use a keyfield in my view header to process a j@v@script if statement:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML {$html_attrs}><HEAD><TITLE>PublicCMS</TITLE>

<?php

$varcms = $data["cms_id"]

?>

<script type=text/javascript>
js_cms_id = <?php echo $varcms; ?>

document.write(js_cms_id);
</SCRIPT>



<META name=GENERATOR content="MSHTML 8.00.7600.16588"></HEAD>
...In my test, I can't seem to get the php variable passed to my script variable. I'm sure this must be done quite often, but I can't seem to do a search in the forum on the word J@V@script.
Ideas?


In order to simplify my test, I added a simple hello world:

<?php

$varcms = $data["cms_id"];

$varcms2 = "hello world";

?>
<script type=text/javascript>
js_cms_id = <?php echo $varcms; ?>;

document.write(js_cms_id);
js_cms_id2 = <?php echo $varcms2; ?>;

document.write(js_cms_id2);
</SCRIPT>

M
mdorren author 7/2/2010



In order to simplify my test, I added a simple hello world:

<?php

$varcms = $data["cms_id"];

$varcms2 = "hello world";

?>
<script type=text/javascript>
js_cms_id = <?php echo $varcms; ?>;

document.write(js_cms_id);
js_cms_id2 = <?php echo $varcms2; ?>;

document.write(js_cms_id2);
</SCRIPT>



False alarm. It seems I can use {$CMS_ID_value} directly in the script. Thanks for your time anyway

M
mdorren author 7/2/2010



False alarm. It seems I can use {$CMS_ID_value} directly in the script. Thanks for your time anyway



OOOOOPPPPPSSSS!!!!!

I spoke too soon. It seems that the code generator will not allow {$CMS_ID_value} to be inside a script. It will pass if I build from the html view, but if I switch to the visual editor and then go back to the html view, it dissapears.
Still need help.... sorry

A
ann 7/5/2010

Hi,
since header is common for all pages you can't access fields here.

As workaround you can take out field values using custom event on the Visual Editor tab.