Just using this module for the first time and it seems to be ticking all of the right boxes so far. Nice work
We often need to insert content, views / pages / etc into complex wrapper pages and this is the case in the project that I'm working on. So I quickly threw together this filter to enable me to insert the FAQ page, as per issue Insertng faq or faq categores into a new page?. This would be a nice feature to add to enable others to avoid enabling the PHP filter [This is so bad, one should never do it]
The code is pasted below. Ignore delta 0, as this relates to something else, and sbc should be replaced with faq. (Eg: The code is from the sbc module and the first filter it defined was one to insert an entire page as defined by a menu item into the content)
<?php
function sbc_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
switch ($op) {
case 'list':
return array(
0 => t('Include content via a menu link_path'),
1 => t('Insert FAQ page'),
);
case 'description':
switch($delta) {
case 0: return t('Include content via a menu link_path');
case 1: return t('Insert FAQ page');
}
case 'prepare':
return $text;
case "process":
switch($delta) {
case 0: return preg_replace_callback('/\[link_path:([^\]]*)\]/', '_sbc_link_path_replacer', $text);
case 1: return preg_replace_callback('/\[faq:?([^\]]*)\]/', '_sbc_faq_replacer', $text);
}
}
}
function sbc_filter_tips($delta, $format, $long = false) {
switch($delta) {
case 0: return t('[link_path:node/123] - insert full text of the specified menu link_path');
case 1: return t('[faq] or [faq:123,questions_inline,categories_inline] - insert FAQ content based on the optional category, question style and category style');
}
}
function _sbc_faq_replacer($matches) {
$tid = 0;
$faq_display = '';
$category_display = '';
if(strlen($matches[1])) {
list($tid, $faq_display, $category_display) = explode(',', $matches[1] .',,');
$tid = (int) $tid;
// These two checks ensure that a typo in the faq_display or category_display string still results in the FAQ showing
if ($faq_display && !in_array($faq_display, array('questions_top', 'hide_answer', 'questions_inline', 'new_page'))) {
$faq_display = '';
}
if ($category_display && !in_array($category_display, array('hide_qa', 'new_page', 'categories_inline'))) {
$category_display = '';
}
}
return faq_page($tid, $faq_display, $category_display);
}
?>
Comments
Comment #1
stella commentedCommitted to 6.x, thanks!
I had to make a few small changes, including disabling caching for that input format.
Cheers,
Stella
Comment #3
stella commentedReleased in faq 6.x-1.9.
Comment #4
tvb commentedThis is great stuff but I cannot find where to tweak the html output...
I would like to add a class to allow additional css styling and remove tags like br and strong. Currently only the class "faq-ul-questions-top" is available.
But where is this done?
EDIT: Solved!
Additional classes have appeared in the HTML code in the mean time. My guess is that some of them were filtered out via input filters, which did not allow for div-tags.