[RP] {FAQ_LIST} - List FAQ items to jump inside the site

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

[RP] {FAQ_LIST} - List FAQ items to jump inside the site

Post by marcus@localhorst »

Hello friends,

here I will post a simple Replacement Tag to generate a List of FAQ items (if you use the new Contentpart FAQ on your site).
No magic here and maybe this will be implemented by oliver g. in future?!
I need that now and so, I wrote it.

PLEASE NOTICE: This is experimental and without guarantee!!

drop the following code into your frontend_render folder and place the {FAQ_LIST} in a CP in your FAQ Article, that's all.

Code: Select all

// RP: {FAQ_LIST} v. 0.1 beta carotin
// by marcus@localhorst
// 01.02.2007 16:52:13
// Info: If you use the new Contenpart FAQ you can place the Tag {FAQ_LIST} above your
// FAQ Article and it will print a List with anchors to your FAQ CPs
// use the ul.faqList class to style the list

// -----------------------------------------------------------------------------
function show_faq_list($id, $db)
{
   $CNT_TMP = '';      
   $sql =  "SELECT * " .
           "FROM " . DB_PREPEND . "phpwcms_articlecontent " .
           "WHERE acontent_aid = " . $id . " " .
           "AND acontent_type = 27 ". // this is the ID for FAQ CP
           "AND acontent_visible = 1 " .
           "AND acontent_trash = 0 " .
           "ORDER BY acontent_sorting, acontent_id;";
           
   
  // echo $sql;       
   if($cresult = mysql_query($sql, $db) or die("error retrieving article from database"))
   {
      while($crow = mysql_fetch_array($cresult))
      
      {
         
       $CNT_TMP .= "<li><a href=\"#faq_id".$crow["acontent_id"]."\">".$crow["acontent_text"]."</a></li>"; 
         
      }
      
     $CNT_TMP= "<ul class=\"faqList\">".$CNT_TMP."</ul>";
   
   }
   return $CNT_TMP;
}

if( ! ( strpos($content["all"],'{FAQ_LIST}')===false ) )
{

   $content["all"] = preg_replace('#\{FAQ_LIST\}#ie', 'show_faq_list($GLOBALS[content][article_id], $db)', $content["all"]);
}
Frontend
Image
Backend
Image

best marcus
indyone_de
Posts: 45
Joined: Fri 15. Dec 2006, 10:32

Re: [RP] {FAQ_LIST} - List FAQ items to jump inside the site

Post by indyone_de »

Hello,

is there any update for this add on? I am afraid not. I just tried it and it doesn't work with R307, unfortunately. :(


Cheers indyone_de
Post Reply