Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 05:46 am EDT

Geeklog Forums

Template Override in GLSP


Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Hello,

I would like to use a different header template for my static pages. I have attempted inserting a value for the $template parameter into the code starting on line 100 (in my file) of static pages/index.php exactly as follows(added param value is in bold):

$retval .= COM_startBlock (stripslashes ($A['sp_title']), '','spheader.thtml'), COM_getBlockTemplate ('_staticpages_block', 'header'));

This doesn't seem to work. I've confirmed that blockheader.thtml is not being overriden. I have also attempted using the "template override" in functions.inc for my theme (Axonz). I had to reinsert the following code into that file as it has been removed from the theme:

$result = DB_query ("SELECT onleft,name FROM {$_TABLES['blocks']} WHERE is_enabled = 1");
$nrows = DB_numRows ($result);
/*for ($i = 0; $i
$A = DB_fetchArray ($result);
if ($A['onleft'] == 1) {
$_BLOCK_TEMPLATE[$A['name']] = 'blockheader.thtml,blockfooter.thtml';
} else {
$_BLOCK_TEMPLATE[$A['name']] = 'blockheader.thtml,blockfooter.thtml';
}
}

$_BLOCK_TEMPLATE['customlogin'] = 'customlogin-header.thtml,customlogin-footer.thtml';
$_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';*/
$_BLOCK_TEMPLATE['_staticpages_block'] = 'spheader.thtml,blockfooter.thtml';

I commented out the loop as the theme does not use "left" or "right" blockheader files. This did not work either. I've searched the forums and have only found one reference to both the template override and the call to COM_startBlock. I used those as a reference and i can't get it to work. The new template file is there and the only actual change is {block_title} uses a different CSS class to center the title. I assume the layout directory is the correct place to put custom .thtml files? Any help would be appreciated.

Thank you,

--aym
--aym
 Quote

Status: offline

destr0yr

Forum User
Full Member
Registered: 07/06/02
Posts: 324
dot dot dot. i had an answer but i didn't read the full question.
ignore this post.

-- destr0yr
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Hahahaha. Understood, yet not completely ignored. That's a rad illustration for your pic!

Thanks for trying,

--aym
--aym
 Quote

tokyoahead

Anonymous
without trying myself, I guess that

$retval .= COM_startBlock (stripslashes ($A['sp_title']), '',
COM_getBlockTemplate ('_new_staticpages_block', 'header'))

should work with

$_BLOCK_TEMPLATE['_new_staticpages_block'] = 'new_spheader.thtml,blockfooter.thtml';

the COM_getBlockTemplate gets a template that is refernced in the first argument.
if you define the value in the functions.php, it should be fine. No?
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Thanks for the reply. I had that block template defined as follows:

$_BLOCK_TEMPLATE['_staticpages_block'] = 'spheader.thtml,blockfooter.thtml';

I think my problem is that the $_BLOCK_TEMPLATE array still has the original "_staticpages_block" value defined as "blockheader.thtml". That is if I'm understanding the data structure right.I'm still getting used to how data is being passed around in GL, and I couldn't find where the $_BLOCK_TEMPLATE initially gets defined, so I didn't realize that I had to explicitly define a new template "name" for the it. Hopefully that solves the problem. For suture reference however, where/how is the $_BLOCK_TEMPLATE array defined?

Thanks a ton for your time,

--aym
--aym
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by averageyoungman: For suture reference however, where/how is the $_BLOCK_TEMPLATE array defined?

Nowhere. You only define it when you want to override any of the default templates.

bye, Dirk
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Thanks Tokyoahead & Dirk.

For some reason I'm not getting it to work. My template file is called "spheader.thtml", and it is in the main layout directory for GL. I changed my functions.php file to include the following:

$_BLOCK_TEMPLATE['_custom_sp_header'] = 'spheader.thtml,blockfooter.thtml';

I then add the "_custom_sp_header" to the call to COM_getBlockTemplate as follows:

COM_getBlockTemplate ('_custom_sp_header', 'header');

Theoretically what I should see is a centered title for my static pages, (which are being used as "intro headers" in topics) as I have created a CSS class called "sptitle" that declares the title centered. I then changed the "blocktitle" class in my "spheader.thtml" file to use that new class, but GL is not using the new header file. I've looked at the source to confirm this. I know it's something I'm doing wrong, but just not sure what it is. If I don't hear back I'll just try and figure it out, but I am a little confused as to exactly which function I should be using for this. The forum posts I've seen (by Dirk) refer to the COM_startBlock function for overriding the templates, however changing the "template to get" in that function didn't work either. I have also tried referring to the array directly when calling COM_getBlockTemplate, as in:

COM_getBlockTemplate($_BLOCK_TEMPLATE['_custom_sp_header'], 'header');

Any takers?

Thanks again,

--aym
--aym
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Someone please give me an excuse to use that dancing banana. I figure if it's going to be there it might as well be put to good use.

Wishing for Bananafication,

--aym
--aym
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512

Why wrap the staticpage in a block? It can still be used as a centerblock without being wrapped in a block.
Just uncheck that option in your staticpage editor. then incorporate that html code that you had in the template file into your staticpage.
If it is just a centered title then this is no extra work at all...

viola Big Celebration ...unless i've totally misunderstood your intent.
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Geez. I suppose posting was still useful but I had no idea I could uncheck that option and implement the formatting myself. I would still like to know why the hell I couldn't get the override to work, nevertheless you have spared me any further self inflicted punishment for now.

I really, really wish there was a sarcastic dancing banana.

Thank you sincerely for your time. Big Celebration

--aym
--aym
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
I'm sure the override works though I've never used it on a staticpage--only left/right blocks... it's probably just something so painfully obvious that we're missing it.
but in the interim... let your bruises heal a bit. Shocked
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
by the way, the staticpages (centerblock or otherwise) are not listed in the gl_blocks table so that code you put up in your theme's functions.php file won't have any effect. $A['name'] is the array of gl block names. You won't find "_staticpages_block" in that table.

you best bet would be your first try... using COM_startBlock... and why that didn't work I don't know except that your function is being called from within the staticpages directory so you may want to adjust the path to the template file. ...just spewing some stuff is all.

hope that helps
 Quote

Status: offline

averageyoungman

Forum User
Chatty
Registered: 02/27/05
Posts: 36
Location:Brooklyn
Clearing the way for further bruises as we speak. Wink

Yeah, I have no clue why it wasn't working initially. It did appear to me however that the hardcoded $template='blockheader.thtml' value in the COM_startBlock function was not being overridden. And knowing that it's being called from within the SP directory makes it all the more preplexing. Is that standard behavior? Or should that hardcoded argument be overridden in a case like that? I gather you must be right, I'm missing something somewhere. Shocked

Regardless yyour earlier suggestion is working quite well for the moment! So thanks again for the help. Hopefully I will be in a better position to do the same for others in the future.

--aym
--aym
 Quote

All times are EDT. The time is now 05:46 am.

  • 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