Main menu

Forum


× Help Forum English

How should I take action to recall a single custom field in my theme?

  • MarcoMeme
  • MarcoMeme's Avatar Topic Author
  • New Member
  • New Member
More
8 years 8 months ago #12285 by MarcoMeme
In ic-rounded custom fields come recalled in this way:
<?php // Custom Fields ?>
<?php if ($CUSTOM_FIELDS): ?>
<?php foreach ($CUSTOM_FIELDS AS $FIELD): ?>
<?php if ($FIELD->title && $FIELD->value) : ?>
<div class="ic-divRow">
<div class="ic-divCell ic-label"><?php echo $FIELD->title;  ?></div>
<div class="ic-divCell ic-value"><?php echo $FIELD->value; ?></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
So they are printed in a column in the section information.
I would need to call up the custom fields individually as should be placed in certain points of my theme.
Not being a phenomenon in php I ask how I should act.
Thanks. ;)

<<L'essere umano può alterare le circostanze della vita alterando il suo atteggiamento mentale>> "William James"

Please Log in or Create an account to join the conversation.

  • Lyr!C
  • Lyr!C's Avatar
  • Administrator
  • Administrator
  • Lead Developer
More
8 years 8 months ago #12292 by Lyr!C
Hello,

So, it's in fact quite easy in a custom theme pack, as you will see (and adapt to yoru own custom fields) ;-)

First, in the top of the YOURTHEME_event.php file, add a code like this :
if ($CUSTOM_FIELDS)
{
    foreach ($CUSTOM_FIELDS AS $FIELD)
    {
        if ($FIELD->slug == 'mycustomslug')
        {
             $mycustomslug_title = isset($FIELD->title) ? $FIELD->title : '';
             $mycustomslug_value = isset($FIELD->value) ? $FIELD->value : '';
        }
        if ($FIELD->slug == 'anothercustomslug')
        {
             $anothercustomslug_title = isset($FIELD->title) ? $FIELD->title : '';
             $anothercustomslug_value = isset($FIELD->value) ? $FIELD->value : '';
        }
	// and do on, for each field
    }
}

Then in HTML content, you can use this:
<label><?php echo $mycustomslug_title;  ?></label>
<div><?php echo  $mycustomslug_value; ?></div>
<label><?php echo $anothercustomslug_title;  ?></label>
<div><?php echo  $anothercustomslug_value; ?></div>

Of course, this code should be adapted to your slugs for custom fields ;-)

Hope this helps ?

Best Regards,
Cyril

Latest version : iCagenda 3.9.8
We recommend every user to keep iCagenda updated.
Don't forget to have your Joomla!™ up-to-date!

Do you like iCagenda?
I would appreciate if you could take 5 minutes to post a review on JED (Joomla Extensions Directory) .

File Attachment:

Please Log in or Create an account to join the conversation.

  • MarcoMeme
  • MarcoMeme's Avatar Topic Author
  • New Member
  • New Member
More
8 years 8 months ago #12298 by MarcoMeme
works perfect, thank you.
but for security I would like your own evaluation of what I wrote:
defined('_JEXEC') or die(); ?>

<?php if ($CUSTOM_FIELDS): ?>

    <?php foreach ($CUSTOM_FIELDS AS $FIELD): ?>
    
        <?php if ($FIELD->slug == 'test1') : ?>
             <?php $test1_title = isset($FIELD->title) ? $FIELD->title : ''; ?>
             <?php $test1_value = isset($FIELD->value) ? $FIELD->value : ''; ?>
        <?php endif; ?>
        
		<?php if ($FIELD->slug == 'test2') : ?>        
             <?php $test2_title = isset($FIELD->title) ? $FIELD->title : ''; ?>
             <?php $test2_value = isset($FIELD->value) ? $FIELD->value : ''; ?>
        <?php endif; ?>
	
	<?php endforeach; ?>

<?php endif; ?>

// after where I wish to recall the fields

<label><?php echo $test1_title;  ?></label>
<div><?php echo  $test1_value; ?></div>

but it only works if recall in my theme not Then in HTML content

B)

<<L'essere umano può alterare le circostanze della vita alterando il suo atteggiamento mentale>> "William James"

Please Log in or Create an account to join the conversation.

  • MarcoMeme
  • MarcoMeme's Avatar Topic Author
  • New Member
  • New Member
More
8 years 8 months ago #12299 by MarcoMeme
sorry for my English

<<L'essere umano può alterare le circostanze della vita alterando il suo atteggiamento mentale>> "William James"

Please Log in or Create an account to join the conversation.

  • Lyr!C
  • Lyr!C's Avatar
  • Administrator
  • Administrator
  • Lead Developer
More
8 years 8 months ago #12322 by Lyr!C
Hi!

but it only works if recall in my theme not Then in HTML content

Your code seems good.
What do you mean by "not then in HTML content" ?

Is your code is working as you expect it to work ?

Latest version : iCagenda 3.9.8
We recommend every user to keep iCagenda updated.
Don't forget to have your Joomla!™ up-to-date!

Do you like iCagenda?
I would appreciate if you could take 5 minutes to post a review on JED (Joomla Extensions Directory) .

File Attachment:

Please Log in or Create an account to join the conversation.

Moderators: Lyr!C
Time to create page: 0.074 seconds

 

Follow Us

Create your Joomla templates with Template Creator CK

acymailing logo new