Main menu

Forum


× Help Forum English

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

  • MarcoMeme
  • Avatar di MarcoMeme Autore della discussione
  • New Member
  • New Member
Di più
8 Anni 8 Mesi fa #12285 da 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"

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • Lyr!C
  • Avatar di Lyr!C
  • Administrator
  • Administrator
  • Lead Developer
Di più
8 Anni 8 Mesi fa #12292 da 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 allegato:

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • MarcoMeme
  • Avatar di MarcoMeme Autore della discussione
  • New Member
  • New Member
Di più
8 Anni 8 Mesi fa #12298 da 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"

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • MarcoMeme
  • Avatar di MarcoMeme Autore della discussione
  • New Member
  • New Member
Di più
8 Anni 8 Mesi fa #12299 da MarcoMeme
sorry for my English

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

Si prega Accedi o Crea un account a partecipare alla conversazione.

  • Lyr!C
  • Avatar di Lyr!C
  • Administrator
  • Administrator
  • Lead Developer
Di più
8 Anni 8 Mesi fa #12322 da 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 allegato:

Si prega Accedi o Crea un account a partecipare alla conversazione.

Moderatori: Lyr!C
Tempo creazione pagina: 0.113 secondi

 

Follow Us

Create your Joomla templates with Template Creator CK

acymailing logo new