Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recherche des catégories par leur url plutôt que par leur id #317

Closed
jerrywham opened this issue Jan 28, 2019 · 0 comments
Closed

Recherche des catégories par leur url plutôt que par leur id #317

jerrywham opened this issue Jan 28, 2019 · 0 comments
Labels
changes new features
Milestone

Comments

@jerrywham
Copy link
Contributor

jerrywham commented Jan 28, 2019

Dans la méthode lastArtList, plutot que de chercher les articles d'une catégorie via l'id de celle-ci, faire la recherche via son url. C'est plus parlant qu'un numéro...

Je propose le code suivant :

if(empty($cat_id)) {
			$motif = '/^[0-9]{4}.(?:[0-9]|home|,)*(?:'.$this->plxMotor->activeCats.'|home)(?:[0-9]|home|,)*.[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
		} else {
			if(is_numeric($cat_id)) # inclusion à partir de l'id de la page
				$motif = '/^[0-9]{4}.((?:[0-9]|home|,)*(?:'.str_pad($cat_id,3,'0',STR_PAD_LEFT).')(?:[0-9]|home|,)*).[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
			else { # inclusion à partir du titre de la categorie
				$cat_id .= '|';
				foreach ($this->plxMotor->aCats as $key => $value) {
					if(strpos($cat_id,$value['url'].'|') !== false) {
						$cats = explode('|',$cat_id);
						if (in_array($value['url'], $cats)) {
							$cat_id = str_replace($value['url'].'|',$key.'|',$cat_id);
						}
					}
				}
				$cat_id = substr($cat_id,0,-1);

				$motif = '/^[0-9]{4}.((?:[0-9]|home|,)*(?:'.$cat_id.')(?:[0-9]|home|,)*).[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
				if (empty($cat_id)) {
					$motif = '/^[0-9]{4}.(?:[0-9]|home|,)*(?:'.$this->plxMotor->activeCats.'|home)(?:[0-9]|home|,)*.[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
				}
			}
			
		}

à la place du code existant.

sudwebdesign added a commit to sudwebdesign/PluXml that referenced this issue Jun 26, 2019
Le format peut être vide maintenant, il sera remplacé avec celui par défaut (ou celui du hook*)
Les Hookers* peuvent utiliser la variable $all pour passer outre (jusqu’à $plxGlob_arts ···)
l'ancienne utilisation du motif est respecté et il est possible de le modifier dans le hook*

*plxShowLastArtList

(Basé sur l'idée de Jerry wham)[pluxml#317]
haruka-7 pushed a commit that referenced this issue Sep 12, 2019
@haruka-7 haruka-7 added the changes new features label Sep 21, 2019
@haruka-7 haruka-7 added this to the PluXml 5.8 milestone Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes new features
Projects
None yet
Development

No branches or pull requests

2 participants