16 Posts
apiceweb
4 years ago
4
Topic

Hi,

I'm creating a portfolio page where I can present my work. I created a multiple selection field because I could have collaborated with more people to carry out my work and I would like to add a class for each value in order to give a different style to each one, plus I would like to add a link to refer to the collaborator's site.

I created a multiple selection field and tried to work with custom attributes by adding the class attribute but it is not displayed in the frontend.

How can I do?

Furthermore, a div is not created for each value, can it depend on the fact that I did not correctly recall the field in my template variation?

<?php $x=$cck->getValue('apice_collaborazione');
  if (empty($x)): ?><?php else: ?>
  <div>
    <label><?php echo $cck->getLabel('apice_collaborazione'); ?>:</label> <?php echo $cck->renderField('apice_collaborazione'); ?>
  </div>
<?php endif; ?>

I am attaching screens.

Thanks and good job
Matteo Fontana

Get a Book for SEBLOD
16 Posts
apiceweb
4 years ago
0
Level 1

Nobody can help me?

Thanks so much
Matteo Fontana

1283 Posts
Bucklash
4 years ago
2
Level 1

Have you tried adjusting field in the _markup.php of template (have to rename to markup.php?

not sure if that is the solution but worth checking out.

Also in before render field can create output:

$fields[‘my_field’]->form = html stuff here....

You would need to grab the $fields[‘my_field’]->options or options2 (can’t remember right now) and do your magic there and then add it to $fields[‘my_field’]->form


maybe other ways, too

16 Posts
apiceweb
4 years ago
1
Level 2

Hi,

thanks for your answer I try but I'm not a expert developer.

I think your solution is a possibility and during that time a I try to experiment different solution; I make that with your solution

$fields['apice_collaborazione']->form = '<div>'."my code".'</div>';

and I try with that:

if($field->name == 'apice_collaborazione')

{

$options = '<div>'.$field->type.'</div>';

}

But I can't understand how to continue, can you help me please?

Thanks
Matteo

1283 Posts
Bucklash
4 years ago
0
Level 3

I’m not near a computer for a while so can’t help more but have you tried to var_dump($fields[‘‘your_field’’]); to see what values you have?

You need to construct the select field..

$fields[‘‘your_field’’]->form = ‘<select>

<option value="volvo" class=“white”>Volvo</option>
<option value="saab" class=“black”>Saab</option>

<optionvalue="mercedes" class=“blue”>Mercedes</option>

<option value="audi" class=“red”>Audi</option>

</select>‘;

Get a VIP membership