News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Aide sur dévellopement d'un mod BBCode

Started by madaj, January 05, 2007, 02:30:50 PM

Previous topic - Next topic

madaj

Je travaille sur le fichier sources/subs.php
Je me suis basé sur le code d'un BBC existant : img
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


Et d'un code que j'ai réussit à faire fonctionné pour le site amazon.fr [nofollow]
array( /*Modif par madaj le 05-01-2007 pour Recherche sur amazon.fr*/
'tag' => 'amazonrfr',
'type' => 'unparsed_content',
'content' => '<a href="http://www.amazon.fr/s/index=blended&field-keywords=$1
),


Mais là je travaille sur un code pour alapage
array( /*Modif par madaj le 05-01-2007 pour Recherche sur alapage.fr*/
'tag' => 'alapage',
'type' => 'unparsed_content',
'content' => '<a href="http://www.alapage.com/mx/?tp=L&fulltext=$1" target="_blank">$1</a><sup><span style="font-size:6pt;color:red;">Alapage.com</span></sup>',
),

jusqu'à là tout fonctionne




Et voici mon problème : pour "width" ou "height" pour le BBCode img
[img width=150 height=100]adresse_de_l'image[/img]

je voudrai ajouter un paramètre optionnel "cat" suivit d'un numéro
[alapage cat=1]nom_du_livre[/alapage]
j'ai fais ceci, mais là, ça ne marche plus  :-[
array( /*Modif par madaj le 05-01-2007 pour Recherche sur alapage.fr*/
'tag' => 'alapage',
'type' => 'unparsed_content',
'parameters' => array(
'cat' => array('optional' => true, 'value' => '&type=$1', 'match' => '(\d+)'),
),
'content' => '<a href="http://www.alapage.com/mx/?tp=L&fulltext=$1{cat}" target="_blank">$1</a><sup><span style="font-size:6pt;color:red;">Alapage.com</span></sup>',
'disabled_content' => '($1)',
),

sachant que j'ai la liste des types des principales catégories de recherches:

  • Informatique = 95
  • Livres français = 1
  • Livres anglais = 101
  • Livres espagnols = 201
  • Musique Pop/Rock = 3
  • Musique classique = 2
  • Jeux vidéo = 52
  • Image & Son = 96
  • Logiciels = 51
  • VHS = 42
  • DVD = 41

Donc s'il y a un pro du php qui peut me donner un coup de main, merci!
(car moi, je débute...)

Advertisement: