Calling Comment_XH in the template

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
beate_r
Posts: 174
Joined: Thu May 22, 2008 11:44 pm
Location: Hessen / Germany

Calling Comment_XH in the template

Post by beate_r » Sun Mar 25, 2012 11:05 pm

Hello,

the owner of one of my older sites wants to have a comment utility added to each page. I intend to use Comments_XH unless someone has a better proposal.

The extension will be a bit tricky because the installation is currently based on CMS 3.1, contains a few plugins, notably xtoc, advanced search and incorporates an SMF-Forum. So for an upgrade to XH i need to verify first if the current functionality can be maintained.


As each page needs its own comment section, to my current understanding Comment_XH has to be called from the template - how? A unique name of the comment file has to be generated somehow. If i compute that from the current heading line (maybe its checksum) i will run into problems if the page is renamend or even deleted. Just brainstoming: maybe there is way to enter the call to comments_xh automativally to a page if there is none...

Has anyone done something similar where i could start with? Any other suggestions, ideas, objections?

Thanks

Beate

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Calling Comment_XH in the template

Post by cmb » Sun Mar 25, 2012 11:57 pm

Hi Beate,

indeed a very fascinating demand! It comes down to the old problem of a missing page ID. Both the page number ($s) and the page heading/url ($h[$s]/$u[$s]) might change over time.
beate_r wrote:maybe there is way to enter the call to comments_xh automativally to a page if there is none
That would not solve the problem that an invariant name for the file has to be found.

IMO the best solution is to use a field in the pagedata. Unfortunately there's still none readily available for such purposes, so the Comments_XH plugin or the template has to be modified for this purpose. Something like the following might suffice:

Code: Select all

$pd = $pd_router->find_page($s);
if (empty($pd['comments_name'])) {
    $pd['comments_name'] = uniqid();
    $pd_router->update($s, $pd);
}
 
An alternative might be the use of a "custom field". This would require the user to add the definition to every page, e.g.

Code: Select all

#CMSimple $comments_name = 'a unique name for the current page';#
This solution has the advantage, that selecting the comment file in the back-end is "somewhat more intuitive" than selecting the right uniqid or an otherwise mangled name.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply