Printing page title from user-tag

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
sandberg

Printing page title from user-tag

Post by sandberg »

I have created a user-defined tag, where I want to get the title of the current page using PHP.

What I really want is to integrate BBClone, a counter, to my site. I must specify the name of the page to BBClone for the stats. The code I want to use on every page is this:

Code: Select all

define("_BBC_PAGE_NAME", "Here is the title");
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
What do I replace "Here is the title" with?
sandberg

Re: Printing page title from user-tag

Post by sandberg »

All I want to know is if there are some predefined PHP-variables to use in my own tags?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Printing page title from user-tag

Post by Ted »

I never put the actual title of the page anywhere to be grabbed.

If you really want to do this, it's a few bits of code.

First, open up lib/content.functions.php and look for (around line 193):

Code: Select all

$title = $contentobj->Name();
Under that, add:

Code: Select all

$gCms->variables['page_title'] = $title;
Save it.

Then, in your tag, do:

Code: Select all

global $gCms;
define("_BBC_PAGE_NAME", $gCms->variables['page_title']);
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Printing page title from user-tag

Post by Ted »

Nope.  {title} is replaced long before plugins are processed.
sandberg

Re: Printing page title from user-tag

Post by sandberg »

Thank you. I guess I don't have much choice.
gnolen

Re: Printing page title from user-tag

Post by gnolen »

Did you manage to get bbclone to work for you?

I'm trying without success.
gnolen

Re: Printing page title from user-tag

Post by gnolen »

I have changed the content.functions.php file.

I made a user defined tag 'stat' stated this:

Code: Select all

global $gCms;
define("_BBC_PAGE_NAME", $gCms->variables['page_title']);
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
But nothing gets registerd in the bbclone. I have tested it with a file and it works all right. I also tested with:

Code: Select all

define("_BBC_PAGE_NAME", "Test");
 define("_BBCLONE_DIR", "bbclone/");
 define("COUNTER", _BBCLONE_DIR."mark_page.php");
 if (is_readable(COUNTER)) include_once(COUNTER);
But still no reaction..

Does the php render different from cms or what should I do? I THINK I have tried everything(absolute path, slashes on different place and so on).

Thankful for any help I can get.

/ Gnolen
Locked

Return to “CMSMS Core”