Форумы / Cotonti / Support / Site navigation row in header.tpl

<<<12

how can I create a plugin to do that?

Trustmaster
#16 05.02.2010 16:34
Nope. If $c is a constant, you could use {PHP.sed_cat.my_category.title}, but if $c is a variable, then you'd need a plugin for that. Except for cases when data is already stored somewhere already.
May the Source be with you!
tensh
#17 05.02.2010 17:42
Stupid question:

what's the difference between $t->parse() and $t->out()? Are there other possibilities?
Trustmaster
#18 05.02.2010 17:54
$t->parse() parses a block (parses subblocks and fills in data) into non-changable representation ready for output
$t->out() sends an already parsed block to output
May the Source be with you!
tensh
#19 05.02.2010 18:03
I use only $t->parse() in plugins. ^^ Is it correct? When out() is useful?
Trustmaster
#20 05.02.2010 19:00
system/core/plug.inc.php does this by default for you:
$t->parse('MAIN');
$t->out('MAIN');
May the Source be with you!
tensh
#21 05.02.2010 19:07
Thank you very much :)
donP
#22 05.02.2010 19:19
None of these arguments match to my needs...
I wanted to know if in global tags (the list of them doesn't really exist yet) there was one outputting me the category title, every moment, in every site part, calling it from header.tpl

I had this need cause I actually use a good plugin I made for myself taht really changes header images and text as I want, depending from list/page/forum category/section... That plugin, indeed, catches the category by reading the url (c=categorycode for lists, id=ID or al=alias for pages, s=section or m=topic in forums) and querying the database to reach the appropriate category and display different images and text according to that place in the website.
This is a problem (and not the only problem, as Trustmaster knows, cause I've to solve the page.php?a=add problem) if I want to use url_rewrite method, cause the plugin couldn't work anymore if in url we have alias.html instead of page.php?al=alias... :(
in [color=#729FCF][b]BLUES[/b][/color] I trust
Trustmaster
#23 06.02.2010 00:47
OK, if you know alias or id in your plugin hooking into header, you can learn page_cat for that alias/id with 1 sql query:
if (empty($c)) {
  $where = empty($alias) ? 'page_id = '.(int)$id : "page_alias = '".sed_sql_prep($alias)."'";
  $cat_row = sed_sql_fetchassoc(sed_sql_query("SELECT page_cat FROM $db_pages WHERE $where"));
  $c = $cat_row['page_cat'];
}
After that you should either set a global variable or assign a tag containing that title:
$cat_title = $sed_cat[$c]['title'];
// OR
$t->assign('CAT_TITLE', $sed_cat[$c]['title']);
and then use either global {PHP.cat_title} (will work in any template and any block where $cat_title exists) or local {CAT_TITLE} (will work only in the template you assign it).
May the Source be with you!
donP
#24 06.02.2010 07:32
I explained bad myself, perhaps...
My plugin already works very well now... the problem would come when I'll use url_rewrite, cause in url we wouldn't have page.php?al=alias or list.php?c=category... but

mysite.net/cat1/subcat1/alias.html

or

mysite.net/cat1/subcat1/

so, I'd have to completely rewrite the plugin (that actually reads id and alias values from url).

Instead, I was now searching for a method to obtain category_name as a global variable to use it in a unique header file to draw the appropriate image logo:
<div id="header" style="position: absolute; margin-top: 8px; margin-left: 11px; width: 749px; background: url('{PHP.sed_cat}') no-repeat center top;">

I wouldn't have this need if customheader/customfooter were a real chance, but actually we can only customize areas (e.g. header.list.tpl, header.page.tpl, NOT header.list.cat1.tpl and header.page.cat1.tpl).
in [color=#729FCF][b]BLUES[/b][/color] I trust
Trustmaster
#25 06.02.2010 14:31
You don't need to read anything from the URL. Use sed_import() and import those from GET parameters as normally. Even if your link is:
mysite.net/cat1/subcat1/alias.html
you can still get alias as normal:
$al = sed_import('al', 'G', 'ALP');
(note: for page.php it will already have been imported even if you hook into header)

And so is for mysite.net/cat1/subcat1/.

URL transformation was designed to be as transparent as possible, so that all the rest works like if there was no transformation at all.
May the Source be with you!
donP
#26 06.02.2010 19:11
In fact, My actual plugin uses
$al = sed_import('al', 'G', 'ALP');
to read alias...
but with url tranformation I have to rewrite all the plugin cause there wouldn't be page.php?al=alias anymore in the url, no?
And, more difficult, for lists, cause there wouldn't be list.php?c=categorcode in url, but only cat1/subcat1/... and so for forums...
You say he url transformation is transparent, but my plugin doesn't work if I activare url_rewrite with tat rules...
in [color=#729FCF][b]BLUES[/b][/color] I trust
Trustmaster
#27 07.02.2010 00:24
It means that your .htaccess rules are incorrect. Contact me via PM, I'll help you setting the urls up.
May the Source be with you!
tensh
#28 08.02.2010 20:47
Oww, if we are already in URLs topic, how to write a function to display nice page urls, that will be compatible with page add? If I use a function shown in Documentation, then after adding a page system redirects me to www.mysite.com/(pageid)/ - which obviously shows error 404.
donP
#29 08.02.2010 22:03
It was my (and many other users) question. Look here: http://www.cotonti.com/forums.php?m=posts&q=5170

But we still haven't answer, I think...
in [color=#729FCF][b]BLUES[/b][/color] I trust

<<<12