I have a ajax template and would like to query the channel to select certain entries for a drop down select. How should I modify the code below to get all the results needed.

Trying to modify the JSON feed for the following: $productSelect = new SelectBox('What would you like to purchase?','Choose a product category'); $productSelect->addItem('Phones','phoneSelect') ->addItem('Notebooks','notebookSelect') ->addItem('Tablets','tabletSelect');

Each addItem needs to be a channel entry. Right now the EE template is not accepting the channel entry call using the modified script below...

$productSelect = new SelectBox('3. Select a Product','---'); {exp:channel:entries channel="product" category="2" dynamic="off" disable="member_data|pagination"} $productSelect->addItem('{title}'); {/exp:channel:entries}

  • 3
    I'm sorry, but why this needs to be a PHP? – Sobral May 20 '14 at 14:55
  • Its part of an ajax query for a chained select article: tutorialzine.com/2011/11/chained-ajax-selects-jquery – Thomas K May 20 '14 at 17:13
  • 1
    Please take a moment to edit your question. As it's written, it's unclear what you are asking. – Anna_MediaGirl May 20 '14 at 18:28
  • It sounds like you want your EE template to return a JSON feed. Is that what you are asking? Agree with @RobsonSobral that this probably does not need to be in PHP. Doesn't appear to be anything here that straight up EE can't handle. Of course you wouldn't be following the tutorial as exactly that way. – AllInOne May 20 '14 at 20:57
  • What does "not accepting the channel entry call" mean exactly? What does the template return? – AllInOne May 23 '14 at 19:11

It sounds like you have PHP Parsing on the template set to input stage instead of output stage, which would cause the PHP to be parsed before the Channel Entries tag, leaving a literal unparsed {title}, but I agree with the commenters on your question, you shouldn't need PHP for this.

  • Thanks that did make it work, I would not know how to do this in EE so I used a PHP tutorial to help get me started. If there are better tutorials for EE please let me know. – Thomas K May 28 '14 at 8:54
  • If you'd like to edit your question to include a sample of the final output you're trying to achieve, someone might be able to show you. Right now I'm unsure why you are using PHP at all to build the markup for a select field. – Derek Jones May 28 '14 at 15:37

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.