ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Weblog:Entries result using PHP/SQL

June 17, 2011 12:53pm

Subscribe [3]
  • #1 / Jun 17, 2011 12:53pm

    fasterhorses

    6 posts

    Hello,

    I have a few PHP variables that I have to pass to an embedded Javascript template. Because of the chicken/egg situation of setting the PHP to input/output & needing PHP to run inside {embed}, I have to write the query in PHP/SQL.

    Essentially, I’m trying to run:

    {exp:weblog:entries weblog="podcasts" status="FC" dynamic="off"}

    and gather the results.

    How would I go about doing this?

    Thanks!

    —Nick

  • #2 / Jun 18, 2011 10:37am

    Greg Salt

    3988 posts

    Hi Nick,

    Can you explain exactly what it is that you need to do? Are you not able to set embed variables from the results of your weblog entries tag?

    Cheers

    Greg

  • #3 / Jun 20, 2011 11:47am

    fasterhorses

    6 posts

    Hey Greg,

    First of all, thanks for getting in-touch.

    Essentially…

    I have {weblog:entries} tag for podcasts (called Podcasts) that contain a custom field for a URL to the podcast’s MP3 (on an Amazon S3 bucket). These weblog entries have two statuses, EJC & FC. I need to loop through the Podcasts weblog entries twice (one for each status) and grab the URL to the MP3 and put them into a PHP array. The result needs to be passed as a variable in an embed tag so it can be used by another template (specifically, a Javascript template that powers a media player). I have confirmed the player to work by hard-coding the result of the array directly into the Javascript template.

    I would normally use a {weblog:entries} tag, but the PHP parsing order is getting in the way:

    If I set to input, the weblog entries won’t output the content to populate the array before the PHP initializes.
    If I set to output, the variable in the embed tag will be rendered as NULL before the PHP array gets populated.

    The solution in my head is to set the parsing order to “input” and to replicate the {weblog:entries} tag in PHP/MySQL, but I’m having trouble getting the desired result.

    Does that make more sense?

    —Nick

  • #4 / Jun 21, 2011 12:39pm

    Sue Crocker

    26054 posts

    Hi, Nick.

    What I’d do is find the exact query you need to get the pieces you want to display. You’ll need to join the exp_channel_titles table and the exp_channel_data table on the entry_id where your status is EJC and FC. You’ll need to know the field you want from the exp_channel_data table to get back.

    Is that enough to get you started?

  • #5 / Jun 21, 2011 12:41pm

    fasterhorses

    6 posts

    Yes! Thank you 😊

  • #6 / Jun 21, 2011 12:44pm

    Sue Crocker

    26054 posts

    Cool. If you need additional help with the query let me know and we can move it to the Community Help forum for additional community support.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases