Wiki Plume Community : PxLastResContent

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Afficher le contenu du dernier article


Pour telle ou telle raison, vous pouvez avoir besoin d'afficher le contenu intégral ou non du dernier article, sur votre première page par exemple. Il vous faut alors ajouter une fonction. Cette fonction a été nommé pxLastResContent; elle a été proposéé par Seb à la demande de Buma.

Maybe you want to display the whole or a part of the last content published on your homepage for example. You have to add a function. This one has been called pxLastResContent and was created by Seb, asked to by Buma.

Il va vous falloir éditer au total, quatre fichiers, mais rassurez-vous, rien de compliqué...

You need to edit four files, but don't worry, it's very easy...

Première étape


Nous avons ici utilisé une fonction PHP qui va sélectionner une partie précise du texte, c'est la fonction "eregi", elle est insensible à la casse, mais je vous conseille de respecter les instructions indiquées.

Here, we've used an eregi function that selects a part of the text.

Dans le fichier, resource_articles.php, retrouvez. Open resource_articles.php and look for this lines...


<?php pxArtPageContent(); ?>


Cette fonction Plume correspond à l'affichage du contenu de votre article. Vous allez l'entourer de commentaire html qui seront reconnu par la fonction eregi dont on a parlé plus haut...

This function displays the content of your article. You're gonna add some html comments at the start and the end of it. They'll be selected by the eregi function.

<!--debutdutexte-->       

    <?php pxArtPageContent(); ?>

<!--findutexte-->   


Voilà qui est fait pour le fichier resource_article.php



Deuxième étape


Comme d'habitude lorsque vous ajouter une fonction à Plume, vous allez créer un fichier my.functions.php si vous n'en possèdez pas déjà un. Vous l'enregistrerez plus tard dans le répoertoire 'Frontinc' où se trouve functions.php

A usual, when you add a function to PLume, you create a my.functions.php file if don't have already one. You'll save it in the 'frontinc' directory wwith the other functions.php file.

Now, you add these lines, the new function.

Mais auparavant, vous allez y ajouter ces lignes de code, la nouvelle fonction en question.


function pxLastResContent($url) {
    //lecture du contenu du fichier
    $content = file_get_contents($url,"r");
    //on isole la selection
    $selection = eregi ('<!--debutdutexte-->(.*)<!--findutexte-->',$content,$regs);
    //on affiche le texte selectionné
    echo $regs[1];
} 


Vous devez maintentant modifier le fichier functions.php et plus précisement, remplacer le fonction pxLastResPath par celle-ci

Now, you have to edit the functions.php file and replace the pxLastResPath function with this one.

function pxLastResPath($type = 'relative', $return=false)
{
    global $_PX_website_config, $_PX_config;
    $s = ($_PX_website_config['secure']) ? 's' : '';
    switch ($type) {
        case 'full' : $path = 'http'.$s.'://'.$_PX_website_config['domain'].$_PX_website_config['rel_url']; break;
        default : $path = $_PX_website_config['rel_url']; break;
    }
    if ($_PX_config['url_format'] == 'simple') {
        $path .= '/?';
    }
    $path .= $GLOBALS['_PX_render']['m']->lres->getPath();
   
    if ($return) return $path;
    echo $path;
}


Enregistrez évidemment les deux fichiers et l'on finalise maintenant nos modifications...

Save the files.


Troisième étape


Ouvrez le fichier prepend.php , toujours dans le même répertoire (/manager/frontinc/prepend.php) et on y ajoute un lien pour mentioner notre fichier my.functions.php

Open prepend.php, in the same directory and add a link to mention your my.function.php file, like this.

include_once $_PX_config['manager_path'].'/frontinc/functions.php';

Sous les autres...

Dernière étape


Théoriquement, tout est en place, vous n'avez plus qu'à appeler la fonction à l'endroit souhaitez avec ces deux lignes que vous intègrez dans votre boucle Last habituelle...

Everything is ready. You just have to add these two lines in your loop, where you want to display the content of the last article published on your website...

<?php  $url = pxLastResPath('full', true);
pxLastResContent($url);?>


Merci encore à Seb pour cette nouvelle fonction qui sera sûrement intègrée dans Plume 1.2

This function will surely be added to Plume 1.2. Thank you Seb.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.1
Page was generated in 1.8676 seconds