0

i have the following Line:

{exp:channel:entries channel="orders"  entry_id_from="{embed:LAST_ID}" sort="desc" dynamic="no"}

LAST_ID file :

<?
include '!mysql.php';
$last_id = @mysql_result(mysql_query('SELECT comanda_id_end FROM output_comenzi ORDER BY id DESC'),0);
if(!$last_id) $last_id = 0;
echo $last_id;
?>

How can I make that the LAST_ID file to get PARSED, take the value and insert it into entry_id_from

Please help :)

1

Your embed syntax is incorrect. {embed:LAST_ID} assumes that the template you're running has been embedded from within another template, and that the parent template's embed code had a parameter named LAST_ID, which has now been passed tot he template you're in.

What I think you are wanting to do it use the value of an embedded template in your channel:entries tag, which you can't do, because embeds run at the very end of the template engine, after all module tags have been run.

But you don't need an embed here, just PHP enabled in your template, set to "Input". Then, change your Channel Entries code to:

entry_id_from="<?php echo $last_id ; ?>"

Also, if the output_comenzi table is located in the same database as your EE tables, you can simplify your query using EE's database class.

$query = ee()->db->query('SELECT comanda_id_end FROM output_comenzi ORDER BY id DESC LIMIT 1');
$last_id = ($query->num_rows() == 1) ? $query->row('comanda_id_end') : 0;
| improve this answer | |
  • Hei Derek, the this is that The file with the entry_id_from="$last_id" must be set on output as i am getting some variables into an array and writing them into a file. How Can I pas $last_id into entry_id_from value? – Klauss Sep 26 '13 at 12:32
  • Input vs Output when enabled PHP in a template has only to do with whether the PHP blocks are processed before or after EE module/plugin tags are processed. – Derek Hogue Sep 26 '13 at 12:34
  • Well, how can I pass the Variable into entry_id_from="here" in Php se on output, is there any way? Other than that is there any PHP syntax to replace Exp Channel Entries ? Is it possible to use with Low variables or any other third plugin ? – Klauss Sep 26 '13 at 12:38
  • You could write a simple plugin that has your last_id value as a variable, and wrap that plugin around your Channel Entries tag, with parse="inward" on it. – Derek Hogue Sep 26 '13 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.