1

It works but it is not great. It's about getting the fields of a subform to display the urls and other fields in a loop

Today I have PHP code:

<?php if (!empty($this->item->jcfields[111]->value)): ?>

    <br /><b><span><i class="fa fa-link fa-1x" aria-hidden="true"></i></span> Pros des films :</b>

        <?php
        $field_value = json_decode($this->item->jcfields[111]->rawvalue);
        $app = Factory::getApplication();
        $factory = $app->bootComponent('com_content')->getMVCFactory();
        $lang="fr";
        $item_id="159";
    ?>

    <?php foreach ($field_value as $value): ?>
        <?php
            $article_id = $value->field110;
            $table = $factory->createTable('Article', 'Table');
            $table->load($article_id);
            $item_catid = $table->catid;
            echo HTMLHelper::link(
                Route::_("/index.php?option=com_content&view=article&id={$article_id}&catid={$item_catid}&Itemid={$item_id}&lang={$lang}"),
                $table->alias
            );    
         ?>
     <?php endforeach ?>

    <?php endif ?>

The rendering is : Pros des films : kamea-meah meteore-films​

Le code HTML est : Code HTML:

<a href="/index.php?option=com_content&amp;view=article&amp; id=119&amp;catid=21&amp;Itemid=159&amp;lang=fr">kamea-meah</a>
<a href="/index.php?option=com_content&amp;view=article&amp; id=122&amp;catid=21&amp;Itemid=159&amp;lang=fr">meteore-films</a>​

1/ how to have a SEF url ? I have set the SEF url in the general config

2/ how to add another subform field and formatting?

Film pros : kamea-meah (production) - meteore-films (direction)

DEBUG

echo '<pre>', print_r($field_value), '</pre>';

=>

stdClass Object
(
[row0] => stdClass Object
(
[field110] => 119
[field112] => Array
(
[0] => film_rea
)

)

[row1] => stdClass Object
(
[field110] => 122
)

)​  

I'll need to retrieve the term "director from the value of "film_rea" custom field

1
  • Hi I have made good progress but I am missing one last point concerning the router.
    – Hdcms
    May 22 at 15:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.