ajouter ce code dans le contrôleur de bas de page opencart:PHP Warning: Chaîne illégale de décalage dans la liste de tableau
$data['tags_name'] = array('inux','ubunuto','php');
foreach ($data['tags_name'] as $tag) {
$data['tags'][] = array(
'title' => $tag['tags_name'],
'href' => $this->url->link('product/search', 'tag=' . $tag['tags_name'])
);
}
Et d'ajouter cette ligne footer.tpl:
<?php foreach ($tags as $tag) { ?>
<li><a class="" target="" href="<?php echo $tag['href']; ?>"><?php echo $tag['title']; ?></a></li>
<?php } ?>
Je vérifie la sortie: print_r($tags);
résultat est:
Array ([0] => Array ([title] => i [href] => http://localhost/opencart/index.php?route=product/search&tag=i)
[1] => Array ([title] => u [href] => http://localhost/opencart/index.php?route=product/search&tag=u)
[2] => Array ([title] => p [href] => http://localhost/opencart/index.php?route=product/search&tag=p))
Je vois seulement le premier mot de balises comme: i
OuOup
Et cette erreur:
Warning: Illegal string offset 'tags_name' in /Applications/XAMPP/xamppfiles/htdocs/opencart/vqmod/vqcache/vq2-system_storage_modification_catalog_controller_common_footer.php
Comment ne peut corriger cette erreur et la sortie ?!
Modifier le '$ tag ['tags_name']' simplement '' $ tag' -> ''title' => $ tag, 'href' => $ this-> url -> link ('product/search', 'tag ='. $ tag'. '['tags_name']' est la clé du tableau de '$ data', mais puisque vous avez' foreach ($ data ['tags_name'] comme $ tag) 'vous êtes déjà à l'intérieur de la clé' ['tags' ']' – Sean
@Sean: Bien sûr que U. fonctionne maintenant – NewCod3r