Page 1 of 1

Printing page title from user-tag

Posted: Mon Jul 18, 2005 9:56 pm
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?

Re: Printing page title from user-tag

Posted: Wed Jul 20, 2005 1:02 pm
by sandberg
All I want to know is if there are some predefined PHP-variables to use in my own tags?

Re: Printing page title from user-tag

Posted: Wed Jul 20, 2005 1:19 pm
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']);

Re: Printing page title from user-tag

Posted: Thu Jul 21, 2005 12:08 am
by Ted
Nope.  {title} is replaced long before plugins are processed.

Re: Printing page title from user-tag

Posted: Tue Jul 26, 2005 10:24 pm
by sandberg
Thank you. I guess I don't have much choice.

Re: Printing page title from user-tag

Posted: Sun Sep 04, 2005 10:59 am
by gnolen
Did you manage to get bbclone to work for you?

I'm trying without success.

Re: Printing page title from user-tag

Posted: Sun Sep 04, 2005 11:52 am
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