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.

Query inside a weblog tag don't work?

June 05, 2008 8:55am

Subscribe [1]
  • #1 / Jun 05, 2008 8:55am

    Joakim_

    33 posts

    Hi there.

    I can’t get this query to run inside a weblog tag.

    {exp:weblog:entries weblog="blog" limit="1" author_id="CURRENT_USER"}
    
    {exp:query sql="SELECT field_id_17 FROM exp_weblog_data WHERE entry_id = '{custom_entry_id}' "}
    
    {field_id_17}
    
    {/exp:query}
    
    {/exp:weblog:entries}

    When I remove the the weblog tag and replaces the {custom_entry_id} with the number, it works.

    Thanks for your help.

  • #2 / Jun 05, 2008 10:02am

    Robin Sowell

    13255 posts

    If you leave the weblog tag in there and hard code the id, does it work?  And to see what’s going on- put it in a test template and turn ‘show queries’ on in ‘Admin- System Prefs- Output and Debug’- it’s a quick way to see if the query is running and if so, what it actually is.  Could be some formating on the custom field adding p tags or something- so query works, just doesn’t return anything.

  • #3 / Jun 05, 2008 11:52am

    Joakim_

    33 posts

    Hi and thanks for the reply.

    I got it working by put it like this:

    {exp:weblog:entries weblog="blog" limit="1" author_id="CURRENT_USER"}
    
    {exp:query sql="SELECT field_id_17 FROM exp_weblog_data WHERE entry_id = '{custom_entry_id}' "}
    
    {/exp:weblog:entries}
    
    {field_id_17}
    
    {/exp:query}
  • #4 / Jun 05, 2008 11:53am

    Robin Sowell

    13255 posts

    Hm- that would make me nervous.  If there’s nothing returned by the weblog tag- or nothing returned by the query- I suspect it would result in broken tags.

    In truth- can’t see why it shouldn’t work if fully nested, and that’s how I’d go at it.  But- your call on whether you think it needs poking a bit more.

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

ExpressionEngine News!

#eecms, #events, #releases