Solarpitch Posted October 22, 2008 Share Posted October 22, 2008 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> "; ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 22, 2008 Share Posted October 22, 2008 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); } Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted October 22, 2008 Author Share Posted October 22, 2008 Hi, yeah, the results from the function need to display within the <div id="results"> tag. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted October 22, 2008 Author Share Posted October 22, 2008 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> ..... ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 22, 2008 Share Posted October 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted October 22, 2008 Author Share Posted October 22, 2008 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> ...... ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.