Count # of items on main page
Rushian 0
From: -
From: -
Notice
This topic is archived. New comments cannot be posted and votes cannot be cast.Responses to this topic
1 Re: Count # of items on main page
Philipp
From: Austria
Administrator
1342From: Austria
Count # of items on main page
Originally posted by Rushian:
No, but you could change in index.php:
to:
This will refresh the cache on the main page every 10 minutes
Originally posted by Rushian:
The caching/template system is different in 2.0. It is much easier in the new version to add dynamic content to the pages.
Originally posted by Rushian:
Is there a way to turn off the caching of the announcement block? I have a hit counter and a little random quotes generator in there, and they don't update when the page is cached..
No, but you could change in index.php:
WriteCache("news", "mainnews", $mainnews, $keepcached);
to:
WriteCache("news", "mainnews", $mainnews, MkTime()+600);
This will refresh the cache on the main page every 10 minutes
Originally posted by Rushian:
Maybe for 2.0 there could be an option to select which blocks are cached?
The caching/template system is different in 2.0. It is much easier in the new version to add dynamic content to the pages.
1 Re: Count # of items on main page
Rushian
OP
0
From: -
From: -
Count # of items on main page
Worked like a charm! Thanks!
Is there a way to turn off the caching of the announcement block? I have a hit counter and a little random quotes generator in there, and they don't update when the page is cached..
Or, is there a better place to put them? I want them after the news block headers, and right before the news_subheader template.
Maybe for 2.0 there could be an option to select which blocks are cached?
Worked like a charm! Thanks!
Is there a way to turn off the caching of the announcement block? I have a hit counter and a little random quotes generator in there, and they don't update when the page is cached..
Or, is there a better place to put them? I want them after the news block headers, and right before the news_subheader template.
Maybe for 2.0 there could be an option to select which blocks are cached?
1 Re: Count # of items on main page
Philipp
From: Austria
Administrator
1342From: Austria
Count # of items on main page
Something like that should work in the main_page template:
Something like that should work in the main_page template:
dbconnect();
$result = DBQuery("SELECT DISTINCT SUBSTRING_INDEX(story_time,' ','1') FROM esselbach_st_stories ORDER BY story_time DESC LIMIT 7");
$dates_query_array = array();
while (list($story_time) = mysql_fetch_row ($result))
{
array_push ($dates_query_array, "(story_time LIKE '%$story_time%')");
}
$dates_query = join(" OR ",$dates_query_array);
$query = DBQuery("SELECT * FROM esselbach_st_stories WHERE $dates_query");
$insert['allnews'] = mysql_num_rows($query);
1 Re: Count # of items on main page
Rushian
OP
0
From: -
From: -
Count # of items on main page
So far so good, but I want to display it in the announce block. I tried using $insert[allnews] in the main_page template, but nothing printed.
I also tried putting the replacement code above in the main_page template PHP section, but it killed the script.
What can I try next?
So far so good, but I want to display it in the announce block. I tried using $insert[allnews] in the main_page template, but nothing printed.
I also tried putting the replacement code above in the main_page template PHP section, but it killed the script.
What can I try next?
1 Re: Count # of items on main page
Philipp
From: Austria
Administrator
1342From: Austria
Count # of items on main page
Open index.php and find:
Then replace with:
Here the template templates/custom_news_count.tmp.php:
Open index.php and find:
while (list($story_time) = mysql_fetch_row ($result))
{
array_push ($story_date_array, "$story_time");
}
}
Then replace with:
$dates_query_array = array();
while (list($story_time) = mysql_fetch_row ($result))
{
array_push ($story_date_array, "$story_time");
array_push ($dates_query_array, "(story_time LIKE '%$story_time%')");
}
$dates_query = join(" OR ",$dates_query_array);
$query = DBQuery("SELECT * FROM esselbach_st_stories WHERE $dates_query");
$insert[allnews] = mysql_num_rows($query);
}
$mainnews .= GetTemplate("custom_news_count");
Here the template templates/custom_news_count.tmp.php:
<?php
global $insert;
$EST_TEMPLATE = <<<TEMPLATE
This page contains $insert[allnews] news
TEMPLATE;
?>
1 Re: Count # of items on main page
Rushian
OP
0
From: -
From: -
Count # of items on main page
All news items displayed on the main page, for as many days I have have set in the website admin.
All news items displayed on the main page, for as many days I have have set in the website admin.
1 Re: Count # of items on main page
Philipp
From: Austria
Administrator
1342From: Austria
Count # of items on main page
Do you want to count all items on the main page or for each day?
Do you want to count all items on the main page or for each day?
Small request:
Is there a way to count the number of news items on the main page? I have my site set to display the last 7 days of news, but the number of items of news per day changes..
Is there a way for ST to count and then display how many news items are actually being displayed?