Different layout for startpage
Different layout for startpage
Hi,
for some time I'm looking for a way to give the start page of the blog a unique style. It should only include the posts and one plug-in. The reason is that I want to include a bigger picture on the start page.
Is this possible??? Can only the start page be embedded?
Hope you guys can help me out!!!
Hannes
for some time I'm looking for a way to give the start page of the blog a unique style. It should only include the posts and one plug-in. The reason is that I want to include a bigger picture on the start page.
Is this possible??? Can only the start page be embedded?
Hope you guys can help me out!!!
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Different layout for startpage
Yes, you can do that with little Smarty templating and some CSS magic.
Look at http://www.s9y.org/forums/viewtopic.php ... p+category or http://www.s9y.org/forums/viewtopic.php ... p+category
You can easily make very different if-structures once you have the "categoryid" variable in your template.
For serendipity 0.9 there's a "categorytemplates" plugin that allows you to have different template for each category, this may also be a solution for you.
Regards,
Garvin
Look at http://www.s9y.org/forums/viewtopic.php ... p+category or http://www.s9y.org/forums/viewtopic.php ... p+category
You can easily make very different if-structures once you have the "categoryid" variable in your template.
For serendipity 0.9 there's a "categorytemplates" plugin that allows you to have different template for each category, this may also be a solution for you.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Thank you for your answer. BUT (this might not be my day)
I don't want the template to be linked with a special category. As I am using no categories (up to now) I don't see this as useful. Only the start page should have a special template. Is it possible to link a plugin with a template? That would make more sense to me (but this must mean nothing ).
Maybe you could bring me on the right way.
Hannes
I don't want the template to be linked with a special category. As I am using no categories (up to now) I don't see this as useful. Only the start page should have a special template. Is it possible to link a plugin with a template? That would make more sense to me (but this must mean nothing ).
Maybe you could bring me on the right way.
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
The current staticpage plugin is able to define a staticpage as "startpage". You can use that plugin's logic to built your own plugin that switches the template for the startpage only.
This is an example; search for "hanno" to see where you need to customize.
Regards,
Garvin
This is an example; search for "hanno" to see where you need to customize.
Code: Select all
<?php
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
class serendipity_event_hanno extends serendipity_event {
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'Hanno');
$propbag->add('description', '');
$propbag->add('event_hooks', array(
'frontend_generate_plugins' => true,
'genpage' => true));
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('stackable', false);
$propbag->add('groups', array('BACKEND_FEATURES'));
}
function generate_content(&$title) {
$title = 'Hanno';
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'genpage':
$args = implode('/', serendipity_getUriArguments($eventData, true));
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = 'customstart';
$serendipity['template'] = 'blue'; // HANNO: Insert your template name for the startpage here.
}
break;
case 'frontend_generate_plugins':
$plugins =& $eventData;
if ($serendipity['GET']['subpage'] != 'customstart') {
return false;
}
foreach ($plugins as $idx => $plugin_data) {
// HANNO: Insert the name of the single plugin you want to keep here.
if ($plugin_data['name'] != 'serendipity_calendar_plugin') {
unset($plugins[$idx]);
}
}
break;
default:
return false;
break;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
Garvin
Last edited by garvinhicking on Thu Sep 08, 2005 3:23 pm, edited 2 times in total.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Thank you very much Garvin. I appreciate your efforts. As I'm (by far) no expert in php and smarty and s9y I would like to ask you some additional questions:
I have copied the code into a new file and called it "serendipity_event_hanno". I created an directory in plugins and copied the file there.
(In line 16 of your code I think there should be a semicolon after true. )
After that I made a new static page called customstart. When I called the site in the browser, the site was displayed with all posts and no sidebar plug-ins, as I have added no plug-in names to the file. The site was displayed with the regular theme. Then I wanted to change the theme for this static site and change line 46 in as I have a simple template. NO changes.
To my surprise the sidebar plug-ins were hidden on all sites not only on this specific static site. After deleting the plug-in the normal layout was displayed of course.
Another questions concerns the "name of the plug-in"? Do you mean the name like saved in the database. Could you give me an example?
Regards,
Hannes
I have copied the code into a new file and called it "serendipity_event_hanno". I created an directory in plugins and copied the file there.
(In line 16 of your code I think there should be a semicolon after true. )
After that I made a new static page called customstart. When I called the site in the browser, the site was displayed with all posts and no sidebar plug-ins, as I have added no plug-in names to the file. The site was displayed with the regular theme. Then I wanted to change the theme for this static site and change line 46 in
Code: Select all
$serendipity['template'] = 'simple';
To my surprise the sidebar plug-ins were hidden on all sites not only on this specific static site. After deleting the plug-in the normal layout was displayed of course.
Another questions concerns the "name of the plug-in"? Do you mean the name like saved in the database. Could you give me an example?
Regards,
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi Hannes!
Regards,
Garvin
That's good so far, and sorry for the typo in line 16.I have copied the code into a new file and called it "serendipity_event_hanno". I created an directory in plugins and copied the file there.
(In line 16 of your code I think there should be a semicolon after true. )
MEEEP! That's an error. Static pages are not involved in the plugin at all.After that I made a new static page called customstart.
You should just call your blog with http://blog/index.php - not the staticpage. Then that template should be shown.When I called the site in the browser, the site was displayed with all posts and no sidebar plug-ins, as I have added no plug-in names to the file. The site was displayed with the regular theme. Then I wanted to change the theme for this static site and change line 46 inas I have a simple template. NO changes.Code: Select all
$serendipity['template'] = 'simple';
I'm sorry, there was yet another bug in my post because the plugins were always removed, no matter if it were the startpage or not. I've corrected the error in the code above.To my surprise the sidebar plug-ins were hidden on all sites not only on this specific static site. After deleting the plug-in the normal layout was displayed of course.
You need to use the "classname" of the plugin, so yes, the name that is stored in the serendipity_plugins table. Usually the filename without ".php".Another questions concerns the "name of the plug-in"? Do you mean the name like saved in the database. Could you give me an example?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Thank you for your reply. I have updated the code and followed the instructions.
The template of the startpage does not change .
It's still not possible to add one or two specific plugins to the startpage . Added the plugin-name like.
Is there some other pre-work to do?
Regards,
Hannes
The template of the startpage does not change .
It's still not possible to add one or two specific plugins to the startpage . Added the plugin-name like
Code: Select all
'serendipity_plugin_xxx';
Is there some other pre-work to do?
Regards,
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
What does your plugin file now look like? What is the URL to your blog you use to see if the template gets applied?
You can try to change this part of the plugin:
Regards,
Garvin
You can try to change this part of the plugin:
Code: Select all
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = 'customstart';
$serendipity['template'] = 'blue'; // HANNO: Insert your template name for the startpage here.
die('TEMPLATE: ' . $serendipity['template']);
} else {
die('You did not simply call the startpage, but supplied GET parameters to the page. Serendipity does not recognize this as your startpage.');
}
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Well, after changing this part of the code it shows the text in the else part. You can check it http://www.hannesreiff.com/new/index.php
The new directory is my serendipity dir.
Regards,
Hannes
The new directory is my serendipity dir.
Regards,
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Okay, that brings us a lot closer to the problem.
could you please use this code:
This should show us what parameters are forcing the page not to be recognized as startpage...
Regards,
Garvin
could you please use this code:
Code: Select all
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = 'customstart';
$serendipity['template'] = 'blue'; // HANNO: Insert your template name for the startpage here.
die('TEMPLATE: ' . $serendipity['template']);
} else {
print_r($args);
print_r($serendipity['indexFile']);
print_r($serendipity['GET']);
die('You did not simply call the startpage, but supplied GET parameters to the page. Serendipity does not recognize this as your startpage.');
}
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
A second idea is this code:
Regards,
Garvin
Code: Select all
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
if ((empty($args) || trim($args) == $serendipity['indexFile']) && (empty($serendipity['GET']['subpage']) || $serendipity['GET']['subpage'] == $nice_url)) {
$serendipity['GET']['subpage'] = 'customstart';
$serendipity['template'] = 'blue'; // HANNO: Insert your template name for the startpage here.
} else {
print_r($nice_url);
print_r($args);
print_r($serendipity['indexFile']);
print_r($serendipity['GET']);
die('You did not simply call the startpage, but supplied GET parameters to the page. Serendipity does not recognize this as your startpage.');
}
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Thank you so much for your efforts!!!
I changed the code with the last improvement. The template is now changing to the one given in the code. It's now the default one.
Links to other subpages or static pages are not working (but I could imagine you know that). Remains the thing with the plugins.
Hannes
I changed the code with the last improvement. The template is now changing to the one given in the code. It's now the default one.
Links to other subpages or static pages are not working (but I could imagine you know that). Remains the thing with the plugins.
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Try to replace the "subpage" with "custompage" in those occurences:
Then you should be able to use it without influencing the staticpages.
About the plugins: How does your actual code look like now? Maybe your if-structure is just wrong...
Regards,
Garvin
Code: Select all
$serendipity['GET']['subpage'] = 'customstart';
...
if ($serendipity['GET']['subpage'] != 'customstart') {
About the plugins: How does your actual code look like now? Maybe your if-structure is just wrong...
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hmm, changed the two lines again - with no visible improvement. It still shows all plugins. the links to the static pages and other subpages don't work.
Here is the plugin if-structure
Are there some mistakes in this structure? Is this correct when I want the comments-plugin to be visible?
Regards,
Hannes
Here is the plugin if-structure
Code: Select all
case 'frontend_generate_plugins':
$plugins = $eventData;
if ($serendipity['GET']['custompage'] != 'customstart') {
return false;
}
foreach ($plugins as $idx => $plugin_data) {
// HANNO: Insert the name of the single plugin you want to keep here.
if ($plugin_data['name'] != 'serendipity_plugin_comments') {
unset($plugins[$idx]);
}
}
Regards,
Hannes
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
The plugin-unsetting is only available in serendipity 0.9, I forgot to mention. You are using that, right?
Can you post me your complete plugin code again, please?
I'm away for the weekend, will reply later.
Regards,
Garvin
Can you post me your complete plugin code again, please?
I'm away for the weekend, will reply later.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/