====== BBCode Plugin trucchetti ====== Traduzione italiana (a tratti libera) del documento [[doc:plugins:bbcode:tips|Adding custom BBCode]]. //[[drudo3@gmail.com|Luciano P.]] 2007/07/05// ===== Come aggiungere un tag personale ===== Se si ha la necessità di aggiungere un nuovo tag BBCode, non è consigliabile modificare il plugin esistente, poichè all' eventuale successivo rilascio di FlatPress si è costretti a rifare da capo la modifica! Si consiglia di creare un **nuovo** plugin in modo da poterlo usare anche nelle successive release. Per altre informazioni sul BBCode di FP leggere questo documento: [[http://www.christian-seiler.de/projekte/php/bbcode/doc/en/chapter1.php|official documentation]]. In questo esempio si vedrà come implementare l' elemento //acronym// grazie ad un tag del tipo [acronym=CSS]Cascading Style Sheet[/acronym] ((se vi state chiedendo se è possibile creare un tag alternativo come ad esempio [acronym=Cascading Style Sheet]CSS[/acronym], sappiate che per ora non è possibile! Non sono infatte ammesse più parole nell' attributo del tag)) che genererà una cosa di questo tipo: CSS custombbcode.php ---------------------- addCode ( 'acronym', // tag name: this will go between square brackets 'callback_replace', // type of action: we'll use a callback function 'plugin_custombbcode_acronym', // name of the callback function array('usecontent_param' => array ('default')), // supported parameters: "default" is [acronym=valore] 'inline', // type of the tag, inline or block, etc array ('listitem', 'block', 'inline', 'link'), // type of elements in which you can use this tag array ()); // type of elements where this tag CAN'T go (in this case, none, so it can go everywhere) $bbcode->setCodeFlag ('acronym', 'closetag', BBCODE_CLOSETAG_MUSTEXIST); // a closing tag is mandatory [/tag] } // $content is the text between the two tags, i.e. [tag]CONTAINED TEXT[/tag] $content='CONTAINED TEXT' // $attributes is an associative array where keys are the tag properties. default is the [tagname=value] property function plugin_custombbcode_acronym($action, $attributes, $content, $params, &$node_object) { if ($action == 'validate') { // not used for now return true; } // [acronym=css]Cascading Style Sheet[/acronym] // will become css return "{$attributes['default']}"; } ?>