Welcome to Geeklog, Anonymous Thursday, November 21 2024 @ 07:25 pm EST

Geeklog Forums

Autotag for the FAQ manager plugin


Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Here's a nice little hack demonstrating what the new autotags (as of Geeklog 1.3.10) are all about.

Add the following piece of code to the FAQ manager's functions.php:
Text Formatted Code
function plugin_autotags_faqman ($op, $content = '', $autotag = '')
{
    global $_CONF, $_TABLES;

    if ($op == 'tagname' ) {
        return 'faq';
    } else if ($op == 'parse') {
        if (is_numeric ($autotag['parm1'])) {
             if (!empty ($autotag['parm2'])) {
                $question = $autotag['parm2'];
            } else {
                $question = DB_getItem ($_TABLES['faq_topics'], 'question',
                                        "topicID = {$autotag['parm1']}");
            }
            if (!empty ($question)) {
                $url = $_CONF['site_url'] . '/faqman/index.php?op=view&t='
                     . $autotag['parm1'];
                $link = '<a href="' . $url . '">' . $question . '</a>';
                $content = str_replace ($autotag['tagstr'], $link, $content);

                return $content;
            } else {
                return '(FAQ topic #' . $autotag['parm1'] . ' not found)';
            }
        } else {
            return '(error in FAQ link)';
        }
    }
}
 

This introduces a new faq: autotag which creates a link to the FAQ topic with the id after the colon. It also pulls the headline (i.e. the question) of the FAQ from the database, so you don't have to enter it yourself. In other words:would be translated into a link to this ever-popular FAQ topic:
Text Formatted Code
<a href="http://www.geeklog.net/faqman/index.php?op=view&t=38">Cannot modify header information - headers already sent by ...</a>
 
But you can also enter your own link text like this
Text Formatted Code
Please read this first
 


There's one minor bug in Geeklog 1.3.10rc1, though: For the first variant (i.e. without your own link text) you currently have to enter a space between the topic ID and the closing square bracket.

To fix this, change line 1004 in system/lib-plugins.php to read
Text Formatted Code
        'parm1'     => str_replace (']', '', $parms[1]),
 
This will also be fixed in rc2.

Now if only the forum would support autotags ...

bye, Dirk
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Dirk: Now if only the forum would support autotags ...


And thanks to Blaine, it does now Cool

So here are the two examples from above again:

----- snip -----

Cannot modify header information - headers already sent by ...

Please read this first.

----- snip -----

Only this time, they're actually interpreted, so you only see the links.

bye, Dirk
 Quote

Aloysius

Anonymous
Dirk/Blaine/anyone else?

You mention that Forum supports autotags. Do I use the same code as in contribution ie. see this in the forum?

I know that we can use the URL to point to the page but how do I use autotag in the forum to point to the staticpage?

Thks Can someone help me plse
 Quote

Aloysius

Anonymous
Sorry, I typed in the autotag code for staticpage and it looks like it works on your forum. Wow!

Now the question is what do I need to do on my site to make it work for my forum?
Doh! - that was a mistake
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The forum here on geeklog.net is somewhat customized ... See if you can find something on Blaine's site.

bye, Dirk
 Quote

All times are EST. The time is now 07:25 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content