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.

Logged_in_member_id in weblog tag as value

February 28, 2009 7:46am

Subscribe [3]
  • #1 / Feb 28, 2009 7:46am

    ron00nor

    52 posts

    Hi,
    Why does this not work:

    {exp:weblog:entries weblog="projecten" search:DBPR_PEID="={logged_in_member_id}" disable="categories|pagination|trackbacks"}
        
    {DBPR_Plaats}
    {/exp:weblog:entries}

    The {logged_in_member_id} does give the right value outside the weblog tag.

  • #2 / Feb 28, 2009 1:31pm

    jpaylor

    84 posts

    Hi ron00nor,

    It is difficult to tell why that would not work because the syntax all appears to be correct.

    Have you tried enabling “Display SQL Queries” in the “Output and Debugging Preferences”? This will display all the queries used to display the data on the page, and you should be able to find a query for your weblog entries tag by searching on the page for “projecten” or possibly “DBPR_PEID”. You will then be able to see if the correct value for {logged_in_member_id} is being used in the query string.

    Also, it may be worth placing some static text in the weblog entries loop, so that it is easier to tell if it is actually looping (because it may be looping, but ‘{DBPR_Plaats}’ could be empty?), for example:

    {exp:weblog:entries weblog="projecten" search:DBPR_PEID="={logged_in_member_id}" disable="categories|pagination|trackbacks"}
        
    DBPR_Plaats = "{DBPR_Plaats}"
    {/exp:weblog:entries}
  • #3 / Mar 01, 2009 10:49am

    ron00nor

    52 posts

    Hi JonnyUK,

    Thanks for checking the code. Outputting SQL gives not much usable. However outputting template parsing shows that the tag defenitionis not complete:

    (0.617633)                 - Beginning Tag Processing - 
    (0.617646)                Parsing Tags in Template
    (0.617662)                Tag: {exp:weblog:entries weblog="projecten" search:DBPR_PEID="={logged_in_member_id}
    (0.617789)                Closing Tag Found
    (0.617831)                Tag: {exp:weblog:entries weblog="projecten" disable="categories|member_data|pagination|trackbacks" limit="500"}
    (0.617908)                Closing Tag Found
    (0.617946)                Processing Tags
    (0.617966)                Module Tag: Weblog/entries
    (0.617980)                Module Tag: Weblog/entries
    (0.617989)                Including Files for Tag and Modules
    (0.617999)                Beginning Final Tag Data Processing
    (0.618009)                Calling Class/Method: Weblog/entries
    (0.618086)                 -> Class Called: Weblog
    (0.618142)                 -> Method Called: entries
    (0.625853)                Returning No Results Content
    (0.625865)                 -> Data Returned

    As you can see the variable {logged_in_member_id} is not evaluated and the closing of the string and tag are missing. Any ideas what can cause this? The content of BDPR_PEID is just simple text as number e.g.: 1802.

  • #4 / Mar 01, 2009 3:11pm

    Mark Bowen

    12637 posts

    I think you are going to need to use PHP turned on to Input mode on the template to do this sort of thing.

    Something like this should get you what you need I think :

    {exp:weblog:entries weblog="default_site" search:DBPR_PEID="=<?php global $SESS; echo $SESS->userdata['member_id']; ?>"}
    <h2>{title}</h2>
    <p>{/exp:weblog:entries}

    Hope that works and helps a bit.

    Best wishes,

    Mark

  • #5 / Mar 02, 2009 2:39pm

    ron00nor

    52 posts

    Hi Mark,

    Thanks for joining me on this one. Your advise really did it! It is sad that the regular variables don’t work in this tag. It is for me always very difficult to know when variables work and when not. E.g in the {if} statement sometimes you need braces and apostrophe while sometimes not.
    In this case php did it but it’s not clean.
    I had used this solution in another template too together with the $_REQUEST getting a posted value and inserted this in the search parameter. I know that when developing that template I also have spent a lot of time figuring the right syntax. Relying on good old php is still in most cases a solution. I hope this can partly be solved with CI in EE 2.0
    Case closed

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

ExpressionEngine News!

#eecms, #events, #releases