[solved] Pb to generate a sublist from linked MM
Hi everyone,
I (still) got 2 MM : mm_evenements and mm_rencontres. mm_rencontres is linked to mm_evenements byt select attribute lienRencontreEvenement.
I got a page with a mm_list of evenements. When clicking, I go to the detail page where I need :
- the informations of the evenement
- a list of referenced mm_rencontres records.
I was told to adapt this example : http://de.contaowiki.org/MetaModels_...ferenced_items . Here is my template code :
PHP Code:
<?php
function getRencontresParEvenement($strAlias, $format='html5')
{
$objMetaModel = MetaModelFactory::byTableName('mm_rencontres'); // my linked mm
$objFilter = $objMetaModel->prepareFilter(16, array()); // I created the filter but added no rules
$objFilter->addFilterRule(new MetaModelFilterRuleSearchAttribute($objMetaModel->getAttribute('lienRencontreEvenement'), $strAlias, $objMetaModel->getAvailableLanguages()));
$objItems = $objMetaModel->findByFilter($objFilter);
return $objItems->parseAll($format, $objMetaModel->getView(20));
}
?>
<div class="evenement_detailview">
<?php foreach ($this->data as $arrItem): ?> // the problem seems to be here (line 13)
<div class="detailview">
<h1 class="ce_headline"><?php echo $arrItem['text']['intitule']; ?></h1>
<p class="description"><?php echo $arrItem['text']['description']; ?></p>
</div>
<div class="rencontres_liees">
<h2>Rencontres</h2>
<?php foreach (getRencontresParEvenement($arrItem['raw']['alias']) as $arrProjects): ?>
<div class="rencontre">
<h3>
<a href="{{env::path}}<?php echo $arrProjects['jumpTo']['url']; ?>">
<?php echo $arrProjects[$this->getFormat()]['intitule']; ?>
</a>
</h3>
<?php echo $arrProjects[$this->getFormat()]['description']; ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
But I got this error message :
Code:
Warning: Invalid argument supplied for foreach() in templates/ce_metamodel_list_test_evenement.html5 on line 13#0 templates/ce_metamodel_list_test_evenement.html5(13): __error(2, 'Invalid argumen...', '/Users/pro/CLIE...', 13, Array)
#1 system/modules/core/library/Contao/BaseTemplate.php(88): include('/Users/pro/CLIE...')
#2 system/modules/core/library/Contao/Template.php(277): Contao\BaseTemplate->parse()
#3 system/modules/core/classes/FrontendTemplate.php(46): Contao\Template->parse()
#4 system/modules/core/classes/Hybrid.php(258): Contao\FrontendTemplate->parse()
#5 composer/vendor/metamodels/core/src/MetaModels/FrontendIntegration/MetaModelHybrid.php(102): Contao\Hybrid->generate()
#6 composer/vendor/metamodels/core/src/MetaModels/FrontendIntegration/HybridList.php(54): MetaModels\FrontendIntegration\MetaModelHybrid->generate()
#7 system/modules/core/library/Contao/Controller.php(476): MetaModels\FrontendIntegration\HybridList->generate()
#8 system/modules/core/modules/ModuleArticle.php(213): Contao\Controller::getContentElement(Object(Contao\ContentModel), 'main')
#9 system/modules/core/modules/Module.php(283): Contao\ModuleArticle->compile()
#10 system/modules/core/modules/ModuleArticle.php(67): Contao\Module->generate()
#11 system/modules/core/library/Contao/Controller.php(409): Contao\ModuleArticle->generate(false)
#12 system/modules/core/library/Contao/Controller.php(269): Contao\Controller::getArticle(Object(Contao\ArticleModel), false, false, 'main')
#13 system/modules/core/pages/PageRegular.php(133): Contao\Controller::getFrontendModule('0', 'main')
#14 system/modules/core/controllers/FrontendIndex.php(267): Contao\PageRegular->generate(Object(Contao\PageModel), true)
#15 index.php(20): Contao\FrontendIndex->run() #16 {main}
What is wrong ? Thanks for your help.