Forum Moderators: coopster

Message Too Old, No Replies

variable inside a function

         

itoo73

11:54 am on May 21, 2010 (gmt 0)

10+ Year Member



Hello everybody,
i need some help. I have a joomla site and in the template i want to write something like this
<?php echo HTML_SOBI::execJPlugins( "{audio}$fieldsFormatted['field_pd']{/audio}" ); ?>.
the execjplugin is a function as far as i know that calls the plugin {audio}.
the $fieldsFormatted['field_pd'] calls the value of the field named pd
If i write
<?php echo HTML_SOBI::execJPlugins( "{audio}somestatictext{/audio}" ); ?>
the plugin works...

if i create an new variable
$test="somestatictext"
and then <?php echo HTML_SOBI::execJPlugins( "{audio}$test/audio}" ); ?>
this works again!
BUT!
i want to give the variable $test the value of the pd field.
So i wrote:
$test=$fieldsFormatted['field_pd']->data;
and then <?php echo HTML_SOBI::execJPlugins( "{audio}$test{/audio}" ); ?>
but the player hangs in buffering! it seems that it finds the file (in cases that it cant its shows error opening file) but it doesnt start! :(((

[edited by: coopster at 2:22 pm (utc) on May 24, 2010]
[edit reason] no personal urls please [/edit]

Matthew1980

12:04 pm on May 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Itoo73,

Welcome to the forum!

$test = $fieldsFormatted['field_pd'];

What ever the value is held in the key 'field_pd' will be copied to $test.

<?php echo HTML_SOBI::execJPlugins( "{audio}".$test."{/audio}" ); ?>

Or from the original verison:-

<?php echo HTML_SOBI::execJPlugins( "{audio}".$fieldsFormatted['field_pd']."{/audio}" ); ?>

Should work too!

Hope I have understood you correctly

Cheers,
MRb

itoo73

1:32 pm on May 21, 2010 (gmt 0)

10+ Year Member



the first solution does the same unfortunately..that is it stucks in buffering.
The second solution gives me an error in the plugin (error opening file)
i send you the whole template in case it helps you..
I am very new to php...
when i give a static text in the $test variable everything works fine. but when i
give the value of field pd in the $test variable the plugin hangs in buffering.
should i put these two lines outside the table? Does this behavior have something to do with a loop? I mean that it seems like it doesnt complete the equalization process of the $test=$fieldsFormatted['field_pd']->data; so that it can move on correctly to the next line. Is this line $test=$fieldsFormatted['field_pd']->data; executed repeatedly so that the other line waits for it to finish? SOrry about my ignorance but i am trying to guess what's happening and cant get it work..

<?php


/*please do not remove this line */
defined( '_SOBI2_' ) || ( trigger_error("Restricted access", E_USER_ERROR) && exit() );

/* ------------------------------------------------------------------------------
* This is the template for the Details View
* ------------------------------------------------------------------------------
*/
?>

<?php HTML_SOBI::renewal( $config,$mySobi ); ?>
<table class="sobi2Details" <?php echo $style; ?> >

<tr></tr>

<tr>
<td><h1><?php echo $mySobi->title; ?></h1></td>
<td align=right><?php echo $ico; ?></td>
</tr>
<tr>
<td><?php echo $img; ?></td>
</tr>
<tr>
<td>
<?php echo $fieldsFormatted['field_owner']; ?><br>
<?php echo $fieldsFormatted['field_street']; ?><br>
<?php echo $fieldsFormatted['field_phone']; ?><br>
<?php echo $fieldsFormatted['field_city']; ?><br>


<?php $test=$fieldsFormatted['field_pd']->data; ?>

<?php echo HTML_SOBI::execJPlugins( "{audio}".$test."{/audio}" ); ?>
</td>
<td align=right><?php echo $plugins["gallery"]; ?></td>



<?php echo Sobi2InsertMod('left') ?>

</tr>
<tr>
<td>
<div id="sobi2outer">

<?php HTML_SOBI::waySearchUrl( $waySearchLink,$config ); ?>
<br>

<br />
</div> </td>
</tr>
</table>
<table class="sobi2DetailsFooter" width="100%">
<tr>
<td>
<?php HTML_SOBI::addedDate($config,$mySobi); ?>
&nbsp;&nbsp;
<?php HTML_SOBI::showHits($config,$mySobi);?>
</td>
<td><?php HTML_SOBI::editButtons($config,$mySobi); ?></td>
</tr>
</table>

Matthew1980

6:40 pm on May 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Itoo73,

What is the contents of $fieldsFormatted['field_pd']->data; ? have you echoed (or print_r'd) the contents to screen to see if it has the contents as you are expecting? :-

echo "<pre>";
print_r($fieldsFormatted['field_pd']->data);
echo "</pre>";

Doing this will echo the contents of the array key to screen, though you could just do:-

echo $fieldsFormatted['field_pd']->data;

as you are looking at a specific key. See if it holds the information as you are expecting and then go from there. I must admit, I have not seen an array key accessed like that before - new to me... Usually the -> part means as it's assigned to a class, or it part of the mysql_fetch_object(); function...

Lets just see if the data is in $fieldsFormatted['field_pd'] or $fieldsFormatted['field_pd']->data first.

[EDIT:] Afterthought: As from your original post it could be as simple as doing this:

<?php echo HTML_SOBI::execJPlugins( "{audio}$fieldsFormatted['field_pd']->data{/audio}" ); ?>

Again though, remove the bolded part if you get an error, as I am still not convinced about using that syntax - maybe someone could enlighten me, though I am pretty sure it's not right.

Cheers,
MRb

itoo73

12:12 pm on May 24, 2010 (gmt 0)

10+ Year Member



Thanx very much...
Finally i got it to work.. I insert it in a if statement and works fine!:) :)