Jump to content

[SOLVED] Parsing issue with template?


Solarpitch

Recommended Posts

Hey guys,

 

I have this section of a template and I'm trying to call the get_products() function to display the results. I'm not sure if that whole if statement parsing is correct. I know the function above it is right as I'm returning the values from a function. But with the get_products() function noting is being returned.

 

You can see where I have $categories->content .= to connect the string again after the php, I'm not sure if this is correct.

 

<?php

        $category = 1;
        $sub_category = 22;

$categories = new page();
$categories->content = "

<div id='range_header'>Ranges</div>
<div id='range_menu'>
<ul>
".get_menu($category)."
</ul>
</div>
</div>

<div id='banner'><img src='designs/banner_bona.png' alt='Bona'></div>

<div id='content_top'>Bona</div>

<div id='results'>";

if(isset($sub_category)){ get_products($sub_category); }

$categories->content .= "</div>

<div class='options_box'>
<a href=''>Enquire about this product</a><br />
<a href=''>Add to Favorites</a>
</div>


</div>


";

?>

Link to comment
Share on other sites

Well, if something IS being returned from that function, the code you have will do nothing with it.

 

Are the results of that function supposed to be added to $categories->content

 

if(isset($sub_category)){ $categories->content .= get_products($sub_category); }

Link to comment
Share on other sites

For example this works perfect... but it wont work with the whole if statement.

 

<?php

.....

<div id='content_top'>Bona</div>

<div id='results'>".

get_products($sub_category)

."</div>

<div class='options_box'>
<a href=''>Enquire about this product</a><br />
<a href=''>Add to Favorites</a>
</div>


</div>

.....

?>

Link to comment
Share on other sites

Did you try the line of code I posted? The way you had it previously you were not using the return values of the function - you were simply calling the function and the results were being thrown away.

 

The example you just posted appear to be that the function is called within an echo statemetn so the results would be echo'd.

 

Example:

function output ()
{
  return "Hello World!";
}

echo output();
//Result: Hello World

output();
//Result: --NOTHING--

 

use the line of code I posted in my first response and I think it will work how you want it.

Link to comment
Share on other sites

Hey,

 

actually.. your code worked fine... thanks.

 

<?php

.....

<div id='range_header'>Engineered Range</div>
<div id='range_menu'>

";

foreach ($category as $arr) { $engineered_flooring->content .= get_menu($arr); }

$engineered_flooring->content .= "

</div>
</div>

<div id='banner'><img src='designs/banner_bona.png' alt='Bona'></div>

......

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.