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.

Nesting exp:weblog:entries or linking members to entries

August 27, 2007 10:14am

Subscribe [2]
  • #1 / Aug 27, 2007 10:14am

    Phoebe

    58 posts

    I have an existing site (http://www.irtpa.com) where there is a weblog with one entry for each real tennis player.  They now want players to have their own blogs.  No problem I thought, but I am currently stuck.  This is what I have so far:

    An existing weblog ‘players’ with one entry per player (I’ve added a blogger_username field to link to member)
    A member is created for each player who wants to blog
    A new weblog ‘blogs’ where the author/username is used to link back to the player.


    Here is the problem.

    I want a page to list all the blog entries for a player, so I have a template that is called .... index.php/tennis/player_blog/joe_soap

    In the template, what I want to do is:

    {exp:weblog:entries weblog="players" ...}     <-- this gets existing info on the player inc. username
    
      {player_pic} etc. 
    
      
      {exp:weblog:entries weblog="blogs" username="{blogger_username}" dynamic="off"}
    
          {title} etc.


    EE doesn’t seem to want to nest exp:weblog:entries.
    I’ve tried this approach

    {exp:weblog:entries weblog="players" ...}  
    
    <?php $blogger="{blogger_username}" ?>
    
    
    {/exp:weblog:entries}
    
        
          
    {exp:weblog:entries weblog="{weblog_name}"  dynamic="off" username="<?php echo $blogger; ?>"}
    
    ...

    The value $blogger is correctly set after the first exp:weblog:entries if php is set to output, but doesn’t get passed as a parameter to the call of the second exp:weblog:entries.
    Also tried this using assign_variable with no success.


    I know EE was not design to do this and if they had specified blogs at the beginning I would have design differently…..

    I can rewrite the weblog:entries as a module to do exactly what I want, just wondered if anyone had any other ideas and could point out a simpler or obvious solution I have missed.

    Phoebe.

  • #2 / Aug 29, 2007 6:04am

    Phoebe

    58 posts

    This is how I got it working in the end.  Not a thing of beauty!

    Set PHP on and to Input

    <h1>Players Profiles</h1>
    
    <?php
    // if passed a number then it will be this players member_id not the entry_id in their profile, so have to convert
    global $DB;
    
    $e="{segment_3}";
    
    if ($e>0) {
       $sql="SELECT m_field_id_1 as profile_id,
                      username
                   FROM exp_member_data d, exp_members m
                   WHERE m.member_id=d.member_id AND 
                         d.member_id=".$e;
       $query=$DB->query($sql);
       if ($query->num_rows>0 && $query->row['profile_id']>0) 
             $_POST['entry_id']=$query->row['profile_id'];
             $_POST['username']=$query->row['username'];
    } 
       
    ?>
    
        
    
    {exp:weblog:entries weblog="players"  limit="1" dynamic="off" dynamic_parameters="entry_id"}
    
       display stuff from first weblog which has player details
    
    {/exp:weblog:entries}
    
    
    
    {exp:weblog:entries weblog="{weblog_name}" orderby="date" sort="desc" dynamic="off" dynamic_parameters="username"}
    
      display stuff from second weblog which has blog entries
     
    {/exp:weblog:entries}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases