Blogger, PHP, and Labels
I'm in the process of updating my Blogger template so that my new Blogger labels and their corresponding label pages have a reasonable user interface and are actually useful. My goals are to:
Once the variable $label is set, I use code such as the following to unconditionally process statements:
I'm still updating my template so things are kind of a mess at the moment. I'm posting this now because I'd love to get feedback on my PHP code and my template. Please post your thoughts and tips as a comment to this blog item - thank you!
Hashtag: # [?]
- Make it clear when a label page is being displayed by including the label name in the page title and in any relevant headers & sidebar sections.
- On the page for a label named label, display my bookmarks that are tagged with label on del.icio.us (and, of course, also display my blog items that are labeled with label).
<MainPage>This sets the $label variable to the upper-cased label name if a label page is being displayed and to NULL if the top page (deflexiοn.com/index) is being displayed. Determining the label name is as simple as determining the page's filename (basename) because Blogger names each label page label.extension and I've set up my blog to use extensionless URLs.
<?php
$label = strtoupper(basename($_SERVER['PHP_SELF']));
if ($label == 'INDEX') {
$label = NULL;
}
// Note: This assumes no label will be named index
?>
</MainPage>
Once the variable $label is set, I use code such as the following to unconditionally process statements:
<?phpNote that this does the right thing on label pages and on the the top page (index). For example, on a label page this resolves to:
echo "$label Deflexions (bookmarks)";
?>
LABEL Deflexions (bookmarks)And on the top page, this resolves to:
Deflexions (bookmarks)To conditionally process statements, I use code like the following:
<?phpNote that on the top page $label is NULL, which is considered FALSE, and statements inside the squiggly brackets will not be run.
if ($label) {
echo "↓ deflexions & reflexions labeled $label";
}
?>
I'm still updating my template so things are kind of a mess at the moment. I'm posting this now because I'd love to get feedback on my PHP code and my template. Please post your thoughts and tips as a comment to this blog item - thank you!
Labels: blogger, labels, php, sitedesign
Hashtag: # [?]
Post & Read Comments (located elsewhere)
Post & Read Comments (located here)
Links to this page
Each item © Nancy McGough
Each comment © the author of the comment
Deflexion.com web site hosted
by DreamHost.com
←
More deflexions & reflexions, & feeds
available via the sidebar
top
&
For bookmarks & links, please use
Post a Comment