Related posts after the main article
En: Is there a plugin to display the titles of related articles (2, 3 or 4) from the same category? With php 8.2 support.
Fr: Existe-t-il un plugin pour afficher les titres de plusieurs articles connexes (2, 3 ou 4) de la même catégorie ? Avec le support de PHP 8.2.
My website micron free. Free hosting: infinityfree.com | php 8.3.27.
Mots clés:
0
Connectez-vous ou Inscrivez-vous pour répondre.

Réponses
Hello,
You probably do not need a plugin if you use built-in function of PluXml:
here is an example to insert in article.php (article-x.php) templates where you want it to appear. It will only show links to article of same category.
<ul> <?php $plxShow->lastArtList('<li><a href="#art_url" title="#art_title">#art_title</a></li>',4, substr($plxShow->artCatIds(), 0, 3)) ?> </ul>Here is the list of the functions that template files can use : https://wiki.pluxml.org/docs/develop/plxshow.html
The plugin you look for might be https://ressources.pluxopolis.net/banque-plugins/plugins/SuggestAvecImage.zip (fr/en languages included)
Cordialement,
gcyrillus , simple membre du forum et utilisateur de PluXml
Mon site PluXml: https://re7net.com | Plugins: https://ressources.pluxopolis.net/banque-plugins/index.php?all_versions | Thèmes: tester et télécharger @ https://pluxthemes.com
Indiquez [RÉSOLU] dans le titre de votre question une fois le soucis réglé, Merci
gcyrillus-nomade, respect!
Great, your code works, I added the date of the article:
<?php $plxShow->lastArtList('#num_day #month #num_year(4). #art_title',4, substr($plxShow->artCatIds(), 0, 3)) ?>My website micron free. Free hosting: infinityfree.com | php 8.3.27.
$plxShow->artCatIds() returns a comma separated list of category ids.
But $plxShow->lastArtList() expects a vertical bar ( | ) separated list as the 3rd parameter.
So here is a better way if an article is owned by several categories :
<?php $template = '#num_day #month #num_year(4). #art_title'; $maxItems = 4; $catList = str_replace(',', '|', $plxShow->artCatIds()); $sortBy = 'rsort'; # may be 'random' or 'alpha' $plxShow->lastArtList($template, $maxItems, $catList, '', $sortBy); ?>Accès à mon dépôt de plugins et thèmes
installe PluXml plus vite que ton ombre avec kzInstall2
To add a few more infos, you might also want to exclude the current article from the list:
<?php // backup the whole list of articles $plxGlob_arts_aFiles = $plxShow->plxMotor->plxGlob_arts->aFiles; // get current article id $currentArtNumber = $plxShow->plxMotor->plxRecord_arts->f('numero'); // get cat id(s) $currentArtCatId = substr($plxShow->artCatIds(), 0, 3); // only the first one $currentArtCatIds = str_replace(',', '|', $plxShow->artCatIds()); // all of them // remove current article from the list unset($plxShow->plxMotor->plxGlob_arts->aFiles[$currentArtNumber]); // extract & print article datas from selected catId(s) $plxShow->lastArtList('#num_day #month #num_year(4). #art_title',4, $currentArtCatIds ) ; // restore the whole list $plxShow->plxMotor->plxGlob_arts->aFiles = $plxGlob_arts_aFiles; ?>@bazooka07 je crois qu'il y a une typo dans https://wiki.pluxml.org/docs/develop/plxshow.html#artcatid (manque le s ou bien cette fonction à été renommée depuis ?)
edit, and the long version restoring the article number and its data (also for infos)
<?php //backup current article article from $plxShow->plxMotor->plxGlob_arts->aFiles $currentArtNumber = $plxShow->plxMotor->plxRecord_arts->f('numero'); $currentArtContent= $plxShow->plxMotor->plxGlob_arts->aFiles[$plxShow->plxMotor->plxRecord_arts->f('numero')]; // get cat id(s)) $currentArtCatId = substr($plxShow->artCatIds(), 0, 3); // only the first one $currentArtCatIds = str_replace(',', '|', $plxShow->artCatIds()); // all of them // remove current article unset($plxShow->plxMotor->plxGlob_arts->aFiles[$currentArtNumber]); // extract article data and select catId(s) $plxShow->lastArtList('#num_day #month #num_year(4). #art_title',4, $currentArtCatIds ) ; // restore removed current article in $plxShow->plxMotor->plxGlob_arts->aFiles for next scripts running $plxShow->plxMotor->plxGlob_arts->aFiles[$currentArtNumber] = $currentArtContent; ?>Cordialement,
gcyrillus , simple membre du forum et utilisateur de PluXml
Mon site PluXml: https://re7net.com | Plugins: https://ressources.pluxopolis.net/banque-plugins/index.php?all_versions | Thèmes: tester et télécharger @ https://pluxthemes.com
Indiquez [RÉSOLU] dans le titre de votre question une fois le soucis réglé, Merci