Category index page
I'm very happy with what I have achieved www.spainonthisday.com and I have several categories and wondered whether an index page - ie listing all the pages in one category is possible to configure to make the site more user-friendly
Many thanks.
Many thanks.
a list of titles by category
For example for category/features i want to see a list of all the feature pages rather than having to look at each page in return
Many thanks
in documents i find
List all pages related to a particular category:
<?php
// Category key
$categoryKey = 'example';
// The category is an Category-Object
$category = getCategory($categoryKey);
// Print the category name
echo 'Category name: ' . $category->name();
// Print the pages title related to the category "example"
foreach ($category->pages() as $pageKey) {
$page = new Page($pageKey);
echo $page->title();
}
?>
But I am unsure which page i should use this code to obtain index pages each listing their own category content
For example for category/features i want to see a list of all the feature pages rather than having to look at each page in return
Many thanks
in documents i find
List all pages related to a particular category:
<?php
// Category key
$categoryKey = 'example';
// The category is an Category-Object
$category = getCategory($categoryKey);
// Print the category name
echo 'Category name: ' . $category->name();
// Print the pages title related to the category "example"
foreach ($category->pages() as $pageKey) {
$page = new Page($pageKey);
echo $page->title();
}
?>
But I am unsure which page i should use this code to obtain index pages each listing their own category content
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
For example if there is a category "food" you can create a template food.php with the code above.
In addition to this you have to modify the template index.php adding the template food.php to the condition $WHERE_AM_I, and use for example:
Now you can create a page with the title (slug) "Food" which uses the template food.php.
In addition to this you have to modify the template index.php adding the template food.php to the condition $WHERE_AM_I, and use for example:
Code: Select all
<?php
if ($WHERE_AM_I == 'page') {
if ($page->slug() == "food") {
include(THEME_DIR_PHP.'food.php');
} else {
include(THEME_DIR_PHP.'page.php');
}
} else {
include(THEME_DIR_PHP.'home.php');
}
?>
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Where should this single line
$categoryKey = $page->slug().
go - in the index.php somewhere here
<?php
// Bludit content are pages
// But if you order the content by date
// These pages works as posts
// $WHERE_AM_I variable detect where the user is browsing
// If the user is watching a particular page/post the variable takes the value "page"
// If the user is watching the frontpage the variable takes the value "home"
if ($WHERE_AM_I == 'page') {
include(THEME_DIR_PHP . 'page.php');
} else {
include(THEME_DIR_PHP . 'home.php');
}
?>
or how as a single template
Many thanks
$categoryKey = $page->slug().
go - in the index.php somewhere here
<?php
// Bludit content are pages
// But if you order the content by date
// These pages works as posts
// $WHERE_AM_I variable detect where the user is browsing
// If the user is watching a particular page/post the variable takes the value "page"
// If the user is watching the frontpage the variable takes the value "home"
if ($WHERE_AM_I == 'page') {
include(THEME_DIR_PHP . 'page.php');
} else {
include(THEME_DIR_PHP . 'home.php');
}
?>
or how as a single template
Many thanks
I have made this template
<?php
// Category key
$categoryKey = 'features';
// The category is an Category-Object
$category = getCategory($categoryKey);
// Print the category name
echo 'Category name: ' . $category->features();
// Print the pages title related to the category "features"
foreach ($category->pages() as $pageKey) {
$page = new Page($pageKey);
echo $page->title();
}
?>
i have made a change to index.php as follows
<?php
if ($WHERE_AM_I == 'page') {
if ($page->slug() == "features") {
include(THEME_DIR_PHP.'features.php');
} else {
include(THEME_DIR_PHP.'page.php');
}
} else {
include(THEME_DIR_PHP.'home.php');
}
?>
Then i went to a written page in the features category to edit and under advanced options and wrote in the template area features.php but it didn't work - the new templates didn't appear
I have placed all the new category templates php in /bi-themes/andy/php/
so features.php
But i couldn't find the created page with the single title
<?php
// Category key
$categoryKey = 'features';
// The category is an Category-Object
$category = getCategory($categoryKey);
// Print the category name
echo 'Category name: ' . $category->features();
// Print the pages title related to the category "features"
foreach ($category->pages() as $pageKey) {
$page = new Page($pageKey);
echo $page->title();
}
?>
i have made a change to index.php as follows
<?php
if ($WHERE_AM_I == 'page') {
if ($page->slug() == "features") {
include(THEME_DIR_PHP.'features.php');
} else {
include(THEME_DIR_PHP.'page.php');
}
} else {
include(THEME_DIR_PHP.'home.php');
}
?>
Then i went to a written page in the features category to edit and under advanced options and wrote in the template area features.php but it didn't work - the new templates didn't appear
I have placed all the new category templates php in /bi-themes/andy/php/
so features.php
But i couldn't find the created page with the single title
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 77 times
- Contact:
This has to be:
Code: Select all
// Print the category name
echo 'Category name: ' . $category->name();
This feature does not work.Then i went to a written page in the features category to edit and under advanced options and wrote in the template area features.php but it didn't work - the new templates didn't appear
You have to create a new page with the title "Features" (slug "features").
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets