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.

acquire author_id from another means besides {segment}

July 12, 2012 4:53pm

Subscribe [3]
  • #1 / Jul 12, 2012 4:53pm

    MarketingMatters

    28 posts

    Are there alternative ways to pass a variable to assign an integer to author_id inside an entries tag OUTSIDE of using segment variables?

    I’ve tried embedding templates and making variables. The variables pass all the way through…UP TO… outside of the actually entries tag.

    I’ve tried preload:replace (passing down the template…up to outside of the entries tag)

    Nothing seems to work but segment.

    Any ideas? Is there a mod for this? Need an example to look at?

    {preload_replace:my_author2='{embed="elements/test"}'} <--- pulls the correct author_id
    
    {my_author2} = correct author_id IN THE TEMPLATE but when editing the entries tag:
    
    {exp:channel:entries channel="advanced_profile" author_id="{my_author2}" show_future_entries="yes" limit="" dynamic="no" disable="pagination|categories"} <--- does not place the author ID in template


    Any help, plugin reference (that will work) or mod to a core file would be of great assistance. Thank you!

  • #2 / Jul 13, 2012 12:01pm

    MarketingMatters

    28 posts

    Any ideas? Working with {segment} but would REALLY like to take {segment} out of author_id=”{segment_#}” and be allowed to pass a working variable in it.

  • #3 / Jul 16, 2012 4:45pm

    Shane Eckert

    7174 posts

    Hello MarketingMatters,

    Thank you for posting your question here on the ExpressionEngine forums.

    Where are you trying to use the author_id? Are you trying to get an author_id from an entry or are you trying to get the current user and set that as a author_id?

    The most direct way to get the author_id is via the channel entries tag.

    Thank you for the clarification.

    Cheers,

  • #4 / Jul 17, 2012 7:35am

    MarketingMatters

    28 posts

    I’m trying to use an entry’s author_id and pull it from one entry and place it into another loop

    exp channel entries channel =“channel 1” author_id=“something” > take “something” and place it into:
    exp channel entries channel =“channel 1” author_id=“something from channel 1”

    I can pull the author_id from channel 1, make it into a preload text replacement / variable (this works) and take that variable and place it into the second loop.

    I’ve tried other means that I can think of, but I can’t seem to get the author_id to place into the second loop without relying on {segment}

  • #5 / Jul 17, 2012 3:18pm

    MarketingMatters

    28 posts

    Did I clarify my request well enough, or do I need to articulate more?

    Is there a solution out there that can handle this?

    Thank you all who are participating in solving this issue I’m having.

  • #6 / Jul 18, 2012 11:29am

    Shane Eckert

    7174 posts

    Hey,

    Sounds like you may need to use an embed variable.

    Step 1 - use the channel entries loop to get the author_id

    Step 2 - use an embed and an embed variable to pass the author_id.

    {embed="ellislab/template" myauthor="author_id"}

    In that embed is another channel entries tag pair that uses the variable myauthor to pass the value to the loop.

    Does that make sense?

    Cheers,

  • #7 / Jul 18, 2012 11:36am

    MarketingMatters

    28 posts

    Why yes it does… and I’m trying that now.
    I tried something similar. I created the embed to generate the Author_ID and stuck that variable in the template where I successfully acquired the embed. Now I’ll try to call that second loop via an embed.

    Thanks. I’ll report in a few the result.

  • #8 / Jul 18, 2012 12:33pm

    MarketingMatters

    28 posts

    No dice or I’m doing it wrong. I’m very familiar with embed variables as I use them quite often. But I always use it for entry_id ad never for author_id until now. I’m going to keep attempting. If you can further your example, or send me an example where it works, I would very very very very VERY much appreciate it. I’m wondering if there’s a bug in the system. I don’t see why this isn’t possible or has given me the headaches that it has given me.

  • #9 / Jul 18, 2012 1:39pm

    Reverie123

    47 posts

    If you don’t want to use embed variables, you could use something like MX Jumper , which allows you to put a piece of content form one part to another part of your template. I did something like this just recently, and I know the documentation is weird on mx jumper so I will give you a direct example.

    {exp:mx_jumper:out_global} 
    {exp:channel:entries channel="something"}
    
    {exp:mx_jumper:put name="pass_author_id"}{author_id}{/exp:mx_jumper:put} 
    
    Note: pass_author_id now retains the author id and can be called like a variable{pass_author_id}
    
    {/exp:channel:entries} 
    
    {exp:channel:entries channel="advanced_profile" author_id="{pass_author_id}" show_future_entries="yes" limit="" dynamic="no" disable="pagination|categories"} 
    
       Whatever you need
    
    {/exp:channel:entries} 
    {/exp:mx_jumper:out_global}

                       
       
    I am still doing tests, but if that doesnt work, you can just do a conditional within it, as you now have the author id from that pass variable.

    {exp:channel:entries channel="advanced_profile" author_id="{pass_author_id}" show_future_entries="yes" limit="" dynamic="no" disable="pagination|categories"} 
    
      {if author_id == "{pass_author_id}"} Whatever you need {/if}
    
    {/exp:channel:entries}

    Hope that helps, there are alternatives to mx jumper but mx jumper is free :D

  • #10 / Jul 18, 2012 1:43pm

    MarketingMatters

    28 posts

    Thanks. I’ll keep hacking at it. I’m in the middle of a dozen things at the moment.

    Yeah, Max Lazar’s plugins are very very useful.

  • #11 / Jul 18, 2012 3:28pm

    MarketingMatters

    28 posts

    OK. Update. I am 97% certain that there is a conflict inside of ExpressionEngine when passing along a variable or string into the Author_id= in the entries tag. I successfully parsed the variable using three or four different methods, including Max Lazar’s MX_JUMPER utility.

    The variable / integer will not parse in the entries tag. Nope, nada, zip, zilch.

    Can ExpressionEngine developers confirm this? I’ve thought up new methods and syntax and tested this for 2 weeks now. I can only use {segment} to acquire an author_id and place it into EE channel entries tag. I cannot use any other method or variable and receive results.

    If I’m mistaken, I’m now wanting to see a functioning solution because I cannot get this to function.

  • #12 / Jul 18, 2012 4:01pm

    MarketingMatters

    28 posts

    forgot to make mention, I’m running EE 2.5.0 in this build

  • #13 / Jul 19, 2012 10:32am

    Shane Eckert

    7174 posts

    Hey,

    Sorry that this has been such a pain!

    Here is your example. Be warned that this could bog things down, so use sparingly.

    Master Template:

    {exp:channel:entries channel="blog" limit="1"}
    {embed='site/emb' myauth="{author_id}"}  
    {/exp:channel:entries}

    The Embed:

    {exp:channel:entries channel="blog" limit="1" author_id="{embed:myauth}"}
    STUFF HERE
    {/exp:channel:entries}

    Does that make sense?

    Cheers,

  • #14 / Jul 19, 2012 10:39am

    MarketingMatters

    28 posts

    Yes. Thanks Shane. Sadly, that’s the exact code I have in one of my tests. No dice on my build. If it’s working in EE standalone, then there’s a probability that there is a conflict with a third party module / extension / plugin in my code. Time to start stripping.

    Ugh. I’m probably going to have to tap some PHP gurus’ expertise to track down any conflicts.

    Thanks again for the help. It doesn’t go unnoticed or unappreciated.

  • #15 / Jul 19, 2012 11:10am

    Shane Eckert

    7174 posts

    Hey MarketingMatters,

    That’s a bummer! Please let me know how it goes, would love to know what in the world would stop this from working.

    It’s my pleasure to help! Thank you for being awesome and using ExpressionEngine!

    I will keep this open and wait for some, hopefully, good news.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases