We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to pass my php value to {exp:channel:entries..}

Development and Programming

Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

Hi

Here is my code

<?php
$current_cat_id=0;
?>
{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_3}'"}
<?php
$current_cat_id='{cat_id}';
echo $current_cat_id;
?>
{/exp:query}


 {exp:channel:entries channel="catalogue" dynamic="no" limit="16" paginate="both" category="<?php echo $current_cat_id;?>"}
.
.
.
.
{/exp:channel:entries}

**** Setting of template: allow php: Yes PHP Parsing Stage: Output

I attach the debugger too Please help me figure out, thanks

[Mod Edit: Moved to the Dev & Programming forum]

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

Print screen of debugger

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

Note: I able to get $current_cat_id value.

       
Arnold van Iterson's avatar
Arnold van Iterson
8 posts
14 years ago
Arnold van Iterson's avatar Arnold van Iterson

I’m not sure, but does this help?

{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '?>{segment_3}<?php’”}

Sorry this does nothing. Time for coffee!

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

let me brief more.

I able to get $current_cat_id=9.

but I cant pass this value to {exp:channel:entries channel="catalogue" dynamic="no" limit="16" paginate="both" category="<?php echo $current_cat_id;?>"}

       
Arnold van Iterson's avatar
Arnold van Iterson
8 posts
14 years ago
Arnold van Iterson's avatar Arnold van Iterson

I think the problem is that you can’t first use EE to find an id, then use php to remember the id. and then again use EE to do a new request.

1) it’s 1 time EE 2) than 1 time php 3) than endresult

So you need to use an other approach.

One solution might be, to first use EE to find the ID, and pass it to an other templates witch handels the second query.

{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_3}’”} {embed="your_template" cat_id="{cat_id}”} {/exp:query}

In the embed template you do: {exp:channel:entries channel="catalogue" dynamic="no" limit="16" paginate="both" category="{embed:cat_id}”} RESULT {/exp:channel:entries}

Hope this helps

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

Hi, Thanks for your reply.

Yes, that is what I meant.

I did accordingly what you had advise, but i still facing issues.

here is my code in my “index” template {exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_3}’”} {embed="catalogue_content" cat_id="{cat_id}”} cat_id i get:{cat_id} {/exp:query}

This is the code for “catalogue_content” template {exp:channel:entries channel="catalogue" dynamic="no" limit="16" paginate="both" category="{embed:cat_id}”} {if no_results} Sorry, no result here! {/if} {/exp:channel:entries}

from my view, the code seem fine, anywhere wrong??

my output at front end for the page, it just display as {embed="catalogue_content" cat_id="11"} cat_id i get:11

please see next post for printscreen.

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

my frontend printscreen

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

oh Yeah!!! Thank you for your great help.

my mistake at embeded path:

{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_3}’”} {embed="catalogue/catalogue_content" cat_id="{cat_id}”} {/exp:query}

Thank you again!

       
Arnold van Iterson's avatar
Arnold van Iterson
8 posts
14 years ago
Arnold van Iterson's avatar Arnold van Iterson

You’re welcome.

       
Forecepts PL's avatar
Forecepts PL
35 posts
14 years ago
Forecepts PL's avatar Forecepts PL

Hi, may i ask you another question too? I post in forum, but still no one assist me.

Please help me look on this thread http://ellislab.com/forums/viewthread/199729/

Thank you

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.