Factorisation d'un template pour les articles

Bonjour à tous,

Je souhaite n'avoir qu'un seul format d'article, j'ai donc crée un fichier php représentant l'affichage d'un article : [em]un-article.php[/em]


Dans mon fichier d'affichage d'article [em]article.php[/em] tout se passe bien en voici le code
[== PHP ==]
<?php while($plxShow->plxMotor->plxRecord_arts->loop()): ?>
<?php include(dirname(__FILE__).'/un-article.php'); ?>
<?php endwhile; ?>


Lors de l'affichage des articles dans ma page [em]home.php[/em]

j'appelle le fichier [em]un-article.php[/em] dans la boucle des articles, or le problème c'est qu'il ne s'en affiche qu'un seul. Voici le contenu de mon fichier [em]home.php[/em]
[== PHP ==]
<?php include(dirname(__FILE__).'/header.php'); ?>	
	<?php while($plxShow->plxMotor->plxRecord_arts->loop()): ?>
        	<?php include(dirname(__FILE__).'/un-article.php'); ?>
	<?php endwhile; ?>

	<div id="pagination">
		<?php $plxShow->pagination(); ?>
	</div>

        ...
        ...

<?php include(dirname(__FILE__).'/footer.php'); ?>


Avez vous des idées du dysfonctionnement ?
D'avance merci.

Réponses

  • StéphaneStéphane Member, Former PluXml Project Manager
    Bonjour

    Il faut faire

    home.php
    [== PHP ==]
    
    <?php include(dirname(__FILE__).'/header.php'); ?>	
    	<?php while($plxShow->plxMotor->plxRecord_arts->loop()): ?>
            	<?php include(dirname(__FILE__).'/un-article.php'); ?>
    	<?php endwhile; ?>
    
    	<div id="pagination">
    		<?php $plxShow->pagination(); ?>
    	</div>
    
            ...
            ...
    
    <?php include(dirname(__FILE__).'/footer.php'); ?>
    

    un-article.php
    [== PHP ==]
    
    
    			<article role="article" id="post-<?php echo $plxShow->artId(); ?>">
    
    				<header>
    					<h1>
    						<?php $plxShow->artTitle('link'); ?>
    					</h1>
    					<p>
    						<?php $plxShow->lang('WRITTEN_BY'); ?> <?php $plxShow->artAuthor() ?> -
    						<?php $plxShow->artDate('#num_day #month #num_year(4)'); ?> -
    						<?php $plxShow->artNbCom(); ?>
    					</p>
    				</header>
    
    				<section>
    					<?php $plxShow->artChapo(); ?>
    				</section>
    
    				<footer>
    					<p>
    						<?php $plxShow->lang('CLASSIFIED_IN') ?> : <?php $plxShow->artCat(); ?> -
    						<?php $plxShow->lang('TAGS') ?> : <?php $plxShow->artTags(); ?>
    					</p>
    				</footer>
    
    			</article>
    
    

    Consultant PluXml

    Ancien responsable du projet (2010 à 2018)

  • Oui c'est ce que j'ai fait au premier jet seulement il me présente toujours le même article
    une erreur apparait en fin de page

    [em]Fatal error: Call to a member function q() on a non-object in D:\xampp\htdocs\PluXml\core\lib\class.plx.show.php on line 1344[/em]
  • StéphaneStéphane Member, Former PluXml Project Manager
    Si tu as une erreur sur la fonction function q() c'est que tu as repris le code du fichier commentaires, utilisé pour affiché le détail d'un article. As-tu réellement testé le code que j'ai mis au dessus ?

    Consultant PluXml

    Ancien responsable du projet (2010 à 2018)

Connectez-vous ou Inscrivez-vous pour répondre.