Bonjour je suis en train de faire un systeme de liste de contenu avec une fonction
En fait on genere des bloc d'article
La premeiere boucle liste les blocs a créer et la seconde les articles
dans mon helper
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	public static function getCustomlist(&$params)
	{
		$list_customblocks = $params->get('add_customblock');
		if ($list_customblocks){
		$db = JFactory::getDbo();
		// Liste les blocs regroupant des articles
		foreach( $list_customblocks as $list_customblocks_idx => $customblock ){
			$queryCustomlist = 'SELECT a.id, a.title, b.name , a.catid, a.created, a.created_by, a.modified, a.modified_by, a.featured FROM #__content  AS a LEFT JOIN #__users AS b ON a.created_by = b.id WHERE catid= '. $customblock->catidlist .' AND state = 1 ORDER BY modified DESC LIMIT '. (int) $params->get('count');
			$db->setQuery( $queryCustomlist );
			$itemsCustomlist = $db->loadObjectList();
                        // créer la liste des article pour un bloc
			foreach ($itemsCustomlist as &$itemCustomlist) {
				$itemCustomlist->link = JRoute::_('index.php?option=com_content&task=article.edit&id='.$itemCustomlist->id);
			}
			$customblock->listitems = $itemCustomlist;
		}
	}
		return $list_customblocks;
	}
Puis dans template
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
foreach( $listCustomlist as $listCustomlist_idx => $customblock ) : ?>
<?php var_dump($customblock) ; ?>
<div class="block <?php echo $customblock->catidlist; ?> well well-small"  style="width:<?php echo $customblock->width; ?>%">
   <h3 class="module-title nav-header">
   <i class="fa fa-user"></i>
   <?php echo JText::_($customblock->nameblockcustom); ?> : </h3>
   <?php		$show_all_link = 'index.php?option=com_content&filter_category_id='.$customblock->catidlist; ?>
   <div style='text-align:right;'>
   <a href='<?php echo $show_all_link ?>' class='adminlink'>
   <?php
   echo JText::_( 'MOD_DASHBOARD_ALL' );
   echo "</a></div>";	?>
   <div class="row-striped" style="height:<?php echo $forceheightblock; ?>">
      <table class="table table-hover">
         <thead>
            <tr>
            <th><?php echo JText::_( 'MOD_DASHBOARD_TITLE' ); ?></th>
            <?php if ($customblock->displautblock) : ?><th><?php echo JText::_( 'MOD_DASHBOARD_AUTHOR' ); ?></th><?php endif; ?>
            <?php if ($customblock->displdateblock) : ?><th><?php echo JText::_( 'MOD_DASHBOARD_DATE' ); ?></th><?php endif; ?>
            </tr>
         </thead>
		<?php var_dump($itemsCustomlist) ; ?>
				<?php foreach ($itemsCustomlist as $customblock) :?>
         <tbody>
            <tr>
            <td>
               <a href="<?php echo $customblock->listitems->link; ?>"><?php echo $customblock->listitems->title; ?>
               <i class="icon-large icon-edit"></i></a>
            </td>
            <?php if ($customblock->displautblock) : ?><td>
               <span class="small">
                  <i class="icon-user"></i>
 
                  <small class="hasTooltip" title="" data-original-title="<?php echo JHtml::tooltipText('MOD_DASHBOARD_MODIFIED_BY')." ". $customblock->listitems->name; ?>"><?php echo $customblock->listitems->name;?> </small>
               </span>
            </td>
            <?php endif; ?>
            <?php if ($customblock->displdateblock) : ?>
            <td>
            <span class="small">
               <i class="icon-calendar"></i> <?php echo JHtml::date($customblock->listitems->modified, 'd M Y'); ?>
            </span>
            </td>
            <?php endif; ?>
         </tr>
      <?php endforeach; ?>
                  </tbody>
      </table>
</div>
</div>
<?php endforeach; ?>
Le soucis c'est qu'il ne me renvoi qu'un article par bloc et pas les X articles et je séche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
var_dump($itemsCustomlist)
dans mon helper est ok renvoit bien la liste des articles mais que depuis le helper
Code : Sélectionner tout - Visualiser dans une fenêtre à part
var_dump($itemsCustomlist)
dans mon template me renvoi bien 1 bloc avec 1 seul article dedans.....
je ne capte pas pourquoi ...
Merci par avance