Main menu

Forum


× Help Forum English

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

  • MarcoMeme
  • Portrait de MarcoMeme Auteur du sujet
  • Nouveau membre
  • Nouveau membre
Plus d'informations
il y a 8 ans 8 mois #12285 par 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"

Connexion ou Créer un compte pour participer à la conversation.

  • Lyr!C
  • Portrait de Lyr!C
  • Administrateur
  • Administrateur
  • Lead Developer
Plus d'informations
il y a 8 ans 8 mois #12292 par 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) .

Fichier attaché :

Connexion ou Créer un compte pour participer à la conversation.

  • MarcoMeme
  • Portrait de MarcoMeme Auteur du sujet
  • Nouveau membre
  • Nouveau membre
Plus d'informations
il y a 8 ans 8 mois #12298 par 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"

Connexion ou Créer un compte pour participer à la conversation.

  • MarcoMeme
  • Portrait de MarcoMeme Auteur du sujet
  • Nouveau membre
  • Nouveau membre
Plus d'informations
il y a 8 ans 8 mois #12299 par MarcoMeme
sorry for my English

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

Connexion ou Créer un compte pour participer à la conversation.

  • Lyr!C
  • Portrait de Lyr!C
  • Administrateur
  • Administrateur
  • Lead Developer
Plus d'informations
il y a 8 ans 8 mois #12322 par 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) .

Fichier attaché :

Connexion ou Créer un compte pour participer à la conversation.

Modérateurs: Lyr!C
Temps de génération de la page : 0.120 secondes

 

Follow Us

Créez vos templates Joomla avec Template Creator CK

acymailing logo new