We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

(Newbie) : layout:set:append issue

How Do I?

Kami's avatar
Kami
8 posts
3 years ago
Kami's avatar Kami

Hi,

I am trying to show two entries from my Administrator channel within an html table.

My code looks the following :

link CODE


The output is shown in the attached file.

(I am really new to ee and still learning about this great tool.)

Thanks for your time and patience.

K.

       
JCOGS Design's avatar
JCOGS Design
148 posts
3 years ago
JCOGS Design's avatar JCOGS Design

EE’s layout variables are only ‘instantiated’ when the template processing is completed - so you cannot access them from within the same template that they are created within.

Separately there is an issue in your template layout - the ‘no results’ block needs to be within the Channel Entries tag pair.

Two solutions:

  • Since you actually have the information you need in the template (to set the layout variables) one option is to skip the layout variables and simply use the channel entries data directly
  • If you need the layout variables later in the template development sequence then you need to put a step from one layout template to a second into your template - all the layout variables you define in the first part will be available in the second.

If you went down the first path you would end up with something like this:

{exp:channel:entries channel='Administrator'  paginate="bottom"}
 {if no_results} 
  There are no registered administrators.
 {/if} 
{if count == 1}
   <table class="table table-hover">
       <thead>
           <tr>
               <th scope="col">First name</th>
               <th scope="col">Last name</th>
               <th scope="col">Username</th>
               <th scope="col"></th>
         </tr>
    </thead>
    <tbody>
{/if}
        <tr>
            <td>{admin_first_name}</td>
            <td>test</td>
            <td>test</td>
        </tr>
{if count == total_results}
    </tbody>
</table>
{/if}
{/exp:channel:entries}

HTH

?

       
Kami's avatar
Kami
8 posts
3 years ago
Kami's avatar Kami

@JCOGS Design - Thanks very much for your help & explanations.

K.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.