how can I create a plugin to do that?
Trustmaster |
|
---|---|
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 |
|
---|---|
Stupid question:
what's the difference between $t->parse() and $t->out()? Are there other possibilities? |
Trustmaster |
|
---|---|
$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 |
|
---|---|
I use only $t->parse() in plugins. ^^ Is it correct? When out() is useful?
|
Trustmaster |
|
---|---|
system/core/plug.inc.php does this by default for you:
$t->parse('MAIN');
$t->out('MAIN'); May the Source be with you!
|
tensh |
|
---|---|
Thank you very much
![]() |
donP |
|
---|---|
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 |
|
---|---|
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'];
}
$cat_title = $sed_cat[$c]['title'];
// OR
$t->assign('CAT_TITLE', $sed_cat[$c]['title']); May the Source be with you!
|
donP |
|
---|---|
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 |
|
---|---|
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'); 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 |
|
---|---|
In fact, My actual plugin uses
$al = sed_import('al', 'G', 'ALP'); 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 |
|
---|---|
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 |
|
---|---|
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 |
|
---|---|
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
|