Hi,
I'd like to insert a piece of php code in the body section like the following
<?php
if('{NameOfField}'==2)
echo 'Important';
?>
but it seems that in the if statement, the field value is null; this is not the case for echo. I tried for other functions, like strcmp, they have the same problem. It seems that when the php code is run, the database is not imported (maybe?).
The other problem which is similar is that I'd like to show the user info based on {cf_user_id} value. My php code in the body section looks like:
<?php
$user =&JFactory::getUser('{cf_user_id}');
echo $user->name;
?>
This has the same problem and the input of getUser function is null. I would appreciate if you help me out.
Thanks.
I'd like to insert a piece of php code in the body section like the following
<?php
if('{NameOfField}'==2)
echo 'Important';
?>
but it seems that in the if statement, the field value is null; this is not the case for echo. I tried for other functions, like strcmp, they have the same problem. It seems that when the php code is run, the database is not imported (maybe?).
The other problem which is similar is that I'd like to show the user info based on {cf_user_id} value. My php code in the body section looks like:
<?php
$user =&JFactory::getUser('{cf_user_id}');
echo $user->name;
?>
This has the same problem and the input of getUser function is null. I would appreciate if you help me out.
Thanks.
Hi,
Could you check your "Body Loop" setting, and make sure it's set to "Inside Body Loop".
/Fredrik
Could you check your "Body Loop" setting, and make sure it's set to "Inside Body Loop".
/Fredrik
hi,
i have just this same problem - i just can't get an incredibly simple bit of php to work in ChronoConnectivity.
In the instance below, the user has just clicked on a link to view the details of a project called Bandstand:
I put in the 'else' bit just to check that $name and {ProjectName} do in fact match. The page returns:
so i am pretty sure the problem is with the "if" statement.
re Fredrik's reply - I don't have the option of changing the BodyLoop to Inside - see http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=3&t=15194, where Max said that option wasn't needed anymore.
can anyone help? thanks!
i have just this same problem - i just can't get an incredibly simple bit of php to work in ChronoConnectivity.
In the instance below, the user has just clicked on a link to view the details of a project called Bandstand:
<?php
$name="{ProjectName}";
if($name=="Bandstand")
echo "Yep, it's Bandstand all right";
else
{echo "nope it aint Bandstand.<br>";
echo "This project is down as being called {ProjectName}, which apparently doesn't match ".$name;}
?>
I put in the 'else' bit just to check that $name and {ProjectName} do in fact match. The page returns:
nope it aint Bandstand.
This project is down as being called Bandstand, which apparently doesn't match Bandstand
so i am pretty sure the problem is with the "if" statement.
re Fredrik's reply - I don't have the option of changing the BodyLoop to Inside - see http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=3&t=15194, where Max said that option wasn't needed anymore.
can anyone help? thanks!
Hi,
As you refer to Max' recent post, I assume you are using the newer v2.0 of ChronoConnectivity. I am not that familiar with it, as I still stick around with the old 1.2. Nevertheless, from what I can read of the source, {fieldname} will not work with php-code, instead you'll have to use $MyRow->fieldname
Edit: Removed reference to obsolete $name.
/Fredrik
As you refer to Max' recent post, I assume you are using the newer v2.0 of ChronoConnectivity. I am not that familiar with it, as I still stick around with the old 1.2. Nevertheless, from what I can read of the source, {fieldname} will not work with php-code, instead you'll have to use $MyRow->fieldname
<?php
if($MyRow->ProjectName == "Bandstand")
echo "Yep, it's Bandstand all right";
else
{echo "nope it aint Bandstand.<br>";
echo "This project is down as being called {ProjectName}, which apparently doesn't match Bandstand";}
?>
Edit: Removed reference to obsolete $name.
/Fredrik
brilliant, works a treat. Thank you
This topic is locked and no more replies can be posted.