[solved]Customize and Separate Custom Fields in CGBlog

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
kalozura
Forum Members
Forum Members
Posts: 39
Joined: Sun Jan 27, 2008 12:03 am
Location: San Diego, California

[solved]Customize and Separate Custom Fields in CGBlog

Post by kalozura »

Hello all

I have created several custom fields in CGblog  and I'm looking to style  and display each of the differently and I was wondering if there  was  a way to separate them in the summary or details template. I want to be able to call out each of them separately. Is that possible?

right now i have default code:

Code: Select all

{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="CGBlogSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}
which calls them all together and in a certain order.

Again, is there a way to pull each custom field separately? Thanks!
Last edited by kalozura on Wed May 05, 2010 2:51 pm, edited 1 time in total.
janb

Re: Customize and Separate Custom Fields in CGBlog

Post by janb »

Hi

Just comment out the foreach section like below and access each field like this:

Code: Select all


{if isset($entry->fields)}
{*
  {foreach from=$entry->fields item='field'}
     <div class="CGBlogSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}: {eval var=$field->value}
        {/if}
     </div>
  {/foreach}
*}

{$entry->fields.0->name} {$entry->fields.0->value}
{$entry->fields.1->name} {$entry->fields.1->value}
{/if}

If you want to know which fields is available, add this to the end of the template:

Code: Select all

{$entry->fields|@print_r}

JanB
Last edited by janb on Wed May 05, 2010 10:34 am, edited 1 time in total.
kalozura
Forum Members
Forum Members
Posts: 39
Joined: Sun Jan 27, 2008 12:03 am
Location: San Diego, California

Re: Customize and Separate Custom Fields in CGBlog

Post by kalozura »

Thanks JanB

This was exactly what I wanted. :)
Larry
Forum Members
Forum Members
Posts: 10
Joined: Sun Sep 07, 2008 9:37 pm

Re: [solved]Customize and Separate Custom Fields in CGBlog

Post by Larry »

I was looking for the same solution for News... Thanks alot. Saved my day :) Good for me they are based on the same setup.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [solved]Customize and Separate Custom Fields in CGBlog

Post by calguy1000 »

These problems are simple
all you have to do is your required reading
like the SMARTY MANUAL.

Too many people ask questions and bump threads and wait days when all they have to do is follow the instructions in the README, do a few google searches, and spend an hours worth of reading.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Modules/Add-Ons”