I'm sending an Ajax request via jQuery to an EE template. This is the entire contents of the EE template:

{exp:channel:entries channel="tours" url_title="<?php echo $_POST["entry"]; ?>" limit="1" dynamic="no"}
    <p>Hello world. {title} - <?php echo $_POST["entry"]; ?></p>

PHP is Enabled for this template in the control panel, and the template has been fully synced to/from DB and filesystem.

When I simplify the file to just the following:

<p>Entry title: <?php echo $_POST["entry"]; ?></p>

It outputs: Entry title: test-entry-name, as $_POST['entry'] is the URL title being sent via Ajax.

However I couldn't get it to return the {title} for the entry no matter what. When I enabled the Output Profiler, this is the query EE is running:

SELECT t.entry_id FROM exp_channel_titles AS t
                LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1409069885  AND (t.expiration_date = 0 OR t.expiration_date > 1409069885) AND t.url_title = '<?php echo $_POST[' AND t.channel_id = '7' AND t.status = 'open' ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 1 

As you can see it's not parsing the PHP properly for some reason, but I can't work out why. Any ideas?



1 Answer 1


Jumped the gun a bit there, I've solved it the moment I posted the question. Hopefully my answer might help someone else having the same problem.

The solution was to change the PHP parsing stage in the template from "Output" to "Input".

  • could u please mark u question as answer?
    – Max Lazar
    Sep 25, 2014 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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