How can we mark new articles with a "NEW" label?
How can we mark new articles with a "NEW" label?
Hi.
I would like the system to automatically add a "NEW" (or other customizable) text label or icon, next to ALL newly added or edited articles/categories, for a specified period.
For example, when I add a new article, I want for one week a label "NEW" next to it, so people know that this is new material in the site.
Likewise, when I add a new category, I want for, e.g. a week, a label "NEW" next to the menu line for this category, so that can people can directly recognize new material.
Can this be done somehow and if yes, how??
I would like the system to automatically add a "NEW" (or other customizable) text label or icon, next to ALL newly added or edited articles/categories, for a specified period.
For example, when I add a new article, I want for one week a label "NEW" next to it, so people know that this is new material in the site.
Likewise, when I add a new category, I want for, e.g. a week, a label "NEW" next to the menu line for this category, so that can people can directly recognize new material.
Can this be done somehow and if yes, how??
About isNew.php
Thanks Pappnase for your reply.
I read the thread you sent me. However, I would like to ask:
1. The code posted at that thread is the whole content of a file named isNew.php ?
2. So, I can create a file named isNew.php with that content, but where do I put isNew.php?
3. Do I need to modify any other files of phpwcms?
4. Does it work with phpwcms_1.1-RC4_2004-06-22 ?
Thanks for your help.
I read the thread you sent me. However, I would like to ask:
1. The code posted at that thread is the whole content of a file named isNew.php ?
2. So, I can create a file named isNew.php with that content, but where do I put isNew.php?
3. Do I need to modify any other files of phpwcms?
4. Does it work with phpwcms_1.1-RC4_2004-06-22 ?
Thanks for your help.
File is NOT already there!
Sorry, folder phpwcms_template/inc_script does not exist in phpwcms_1.1-RC4_2004-06-22.
Is there a way I can use the script in my version and how ? (It's too difficult to upgrade in my case.)
Thanks for your reply, anyway.
Is there a way I can use the script in my version and how ? (It's too difficult to upgrade in my case.)
Thanks for your reply, anyway.
Upgrade dificult!
Due to many modified pieces of code for better support of greek and many other changes which I don't know if the new version supports them! See my thread: http://www.phpwcms.de/forum/viewtopic.php?t=10582
Thanks for your interest.
Thanks for your interest.
To support using the replacement tag ...just add *another* modification to your list...
In "content.func.inc.php" choose a similar and easy to FIND place such as:
REPLACE with:
AND in "front.func.inc.php" FIND:
and REPLACE with:
In "content.func.inc.php" choose a similar and easy to FIND place such as:
Code: Select all
// include external HTML page but only part between <body></body>
$content["all"] = preg_replace('/\{URL:(.*?)\}/ie', 'include_url("$1");', $content["all"]);
// -------------------------------------------------------------
Code: Select all
// include external HTML page but only part between <body></body>
$content["all"] = preg_replace('/\{URL:(.*?)\}/ie', 'include_url("$1");', $content["all"]);
// -------------------------------------------------------------
// include isNew image at location of replacement tag with format {D:startdate,duration,imagename}
$content["all"] = preg_replace('/\{D:(.*?)\}/ie', 'myRT1("$1")', $content["all"]);
// -------------------------------------------------------------
Code: Select all
// -------------------------------------------------------------
function include_url($url) {
// include given URL but only take content between <body></body>
$k = '';
$url = trim($url);
if($url && function_exists('file_get_contents')) {
$GLOBALS['include_urlparts'] = parse_url($url);
if(isset($GLOBALS['include_urlparts']['path']) && $GLOBALS['include_urlparts']['path']) {
$GLOBALS['include_urlparts']['path'] = dirname($GLOBALS['include_urlparts']['path']);
$GLOBALS['include_urlparts']['path'] = str_replace("\\", '/', $GLOBALS['include_urlparts']['path']);
}
$k = @file_get_contents($url);
$k = preg_replace("/.*<body[^>]*?".">(.*?)<\/body>.*/si", "$1", $k);
$k = str_replace('<?', '<?', $k);
$k = str_replace('?>', '?>', $k);
$k = str_replace('<%', '<%', $k);
$k = str_replace('%>', '%>', $k);
//$k = preg_replace_callback('/(href|src|action)=[\'|"](.*?)[\'|"]/i', 'make_absoluteURL', $k);
$k = preg_replace_callback('/(href|src|action)=[\'|"]{0,1}(.*?)[\'|"]{0,1}( .*?){0,1}>/i', 'make_absoluteURL', $k);
$GLOBALS['include_urlparts'] = '';
}
return $k;
}
// -------------------------------------------------------------
Code: Select all
// -------------------------------------------------------------
function include_url($url) {
// include given URL but only take content between <body></body>
$k = '';
$url = trim($url);
if($url && function_exists('file_get_contents')) {
$GLOBALS['include_urlparts'] = parse_url($url);
if(isset($GLOBALS['include_urlparts']['path']) && $GLOBALS['include_urlparts']['path']) {
$GLOBALS['include_urlparts']['path'] = dirname($GLOBALS['include_urlparts']['path']);
$GLOBALS['include_urlparts']['path'] = str_replace("\\", '/', $GLOBALS['include_urlparts']['path']);
}
$k = @file_get_contents($url);
$k = preg_replace("/.*<body[^>]*?".">(.*?)<\/body>.*/si", "$1", $k);
$k = str_replace('<?', '<?', $k);
$k = str_replace('?>', '?>', $k);
$k = str_replace('<%', '<%', $k);
$k = str_replace('%>', '%>', $k);
//$k = preg_replace_callback('/(href|src|action)=[\'|"](.*?)[\'|"]/i', 'make_absoluteURL', $k);
$k = preg_replace_callback('/(href|src|action)=[\'|"]{0,1}(.*?)[\'|"]{0,1}( .*?){0,1}>/i', 'make_absoluteURL', $k);
$GLOBALS['include_urlparts'] = '';
}
return $k;
}
// -------------------------------------------------------------
function myRT1($rtinfo) {
$dateImage = '';
$rtinfo = explode(',', $rtinfo);
$startDate = strtotime($rtinfo[0]);
$timeout = isset($rtinfo[1]) ? intval($rtinfo[1]) : 0;
$timeout = $timeout * 24 * 3600;
if(time() - $timeout < $startDate) {
$dateImage = '<img src="picture/myRT1/'.$rtinfo[2].'" alt="'.$rtinfo[0].'" border="0">';
}
return $dateImage;
}
// -------------------------------------------------------------
How we use the tag with articles?
Thank you all guys for your prompt reply and for all the support.
I have done these changes, then placed the tag in the category title, and it works! Great.
Yet, how I can use the tag (or modify something) so that the "NEW" icon is automatically placed next to ALL articles (that satisfy a date condition of course) included in a category WITHOUT having to modify the title of each?
In essence, what I would like to do is to automatically make all articles include in their title the {D:...} tag with start date the last_edit_date of each article. What should I do???
I would like to have the icon displayed next to article title in the category list of articles (which is always displayed when a visitor goes to the category page and also in artlicle lists produced by the following tag: {NEWCATID:X:X}.
I have done these changes, then placed the tag in the category title, and it works! Great.
Yet, how I can use the tag (or modify something) so that the "NEW" icon is automatically placed next to ALL articles (that satisfy a date condition of course) included in a category WITHOUT having to modify the title of each?
In essence, what I would like to do is to automatically make all articles include in their title the {D:...} tag with start date the last_edit_date of each article. What should I do???
I would like to have the icon displayed next to article title in the category list of articles (which is always displayed when a visitor goes to the category page and also in artlicle lists produced by the following tag: {NEWCATID:X:X}.
Do you mean like was suggested by OliverG for applying GT Mod to all article titles??
http://www.phpwcms.de/forum/viewtopic.php?p=23450#23450
http://www.phpwcms.de/forum/viewtopic.php?p=23450#23450
{D:...} In all article titles
Thanks Dexxus,
I see that I can use tags in article templates. Unfortunately, I am using many templates, so I have to modify things in many, I guess. But this is the solution, thanks.
I hope I'll have things working soon.
I see that I can use tags in article templates. Unfortunately, I am using many templates, so I have to modify things in many, I guess. But this is the solution, thanks.
I hope I'll have things working soon.
Can a date parameter be used in {D:...} tag?
Please, would someone know: In the {D} tag, for example in {D:2005/9/4,30,newR.gif}, can I use a variable/parameter instead of a particular date?
In particular:
If I use the {D} tag in an article template (in the title) or in:
...Can I somehow reference the article date as a start_date in the {D} tag, so that periods of displaying the NEW icon count automatically from the date each article was last edited?
Otherwise, if I use the same hard-coded date in an article template, all articles would appear new for the same period, which is not true.
Thanks for all the help.
In particular:
If I use the {D} tag in an article template (in the title) or in:
Code: Select all
$template_default["article"]["title_before"] = '<span class="articleHead">';
$template_default["article"]["title_after"] = ' {D:start_date,30,newR.gif} </span>';
Otherwise, if I use the same hard-coded date in an article template, all articles would appear new for the same period, which is not true.
Thanks for all the help.
Just a WILD guess.
I wonder if you could get by with using {DATE_ARTICLE} embedded in your other Rep Tag somehow? Like:
You would UNDO and REDO like this: ( moves {D:startdate,duration,imagename} Rep Tag "parsing" to right after {DATE_ARTICLE} "parsing" ):
In "content.func.inc.php"
REPLACE:
WITH:
NOTE: Even just moving to anywhere after the {DATE_ARTICLE} code in "content.func.inc.php" would suffice.
I wonder if you could get by with using {DATE_ARTICLE} embedded in your other Rep Tag somehow? Like:
Code: Select all
$template_default["article"]["title_before"] = '<span class="articleHead">';
$template_default["article"]["title_after"] = ' {D:{DATE_ARTICLE},30,newR.gif} </span>';
In "content.func.inc.php"
REPLACE:
Code: Select all
// date replacement
if( ! ( strpos($content["all"],'{DATE_')===false ) ) {
$content["all"] = str_replace('{DATE_LONG}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"]), $content["all"]);
$content["all"] = str_replace('{DATE_MEDIUM}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"]), $content["all"]);
$content["all"] = str_replace('{DATE_SHORT}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"]), $content["all"]);
$content["all"] = str_replace('{DATE_ARTICLE}', international_date_format($template_default["date"]["language"], $template_default["date"]["article"], $content["article_date"]), $content["all"]);
}
// -------------------------------------------------------------
Code: Select all
// date replacement
if( ! ( strpos($content["all"],'{DATE_')===false ) ) {
$content["all"] = str_replace('{DATE_LONG}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"]), $content["all"]);
$content["all"] = str_replace('{DATE_MEDIUM}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"]), $content["all"]);
$content["all"] = str_replace('{DATE_SHORT}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"]), $content["all"]);
$content["all"] = str_replace('{DATE_ARTICLE}', international_date_format($template_default["date"]["language"], $template_default["date"]["article"], $content["article_date"]), $content["all"]);
}
// -------------------------------------------------------------
// include isNew image at location of replacement tag with format {D:startdate,duration,imagename}
$content["all"] = preg_replace('/\{D:(.*?)\}/ie', 'myRT1("$1")', $content["all"]);
// -------------------------------------------------------------
{DATE_ARTICLE} nested in {D:start_date,duration,image}
Thanks DeXXus,
Your trick worked! I did in:
But the NEW icon appears only in the full article listing and nowhere else. For example see (I know you cannot read greek, but you'll see what I mean): http://www.unborn.gr/unborn1/unborn/ind ... 93,0,0,1,0
(the NEW icon appears next to the title).
However the NEW icon does not appear next to the article title in the category: http://www.unborn.gr/unborn1/unborn/ind ... rentevents (it is the first article, the only one which appears with a summary)
What should I change so that the NEW icon is displayed in the article title when the category is displayed (both when the article is displayed with a summary and when it is displayed only in the list)?
Additionally, the NEW icon is not displayed when a list is displayed using the {NEWCATID:X:X}. See: http://www.unborn.gr/unborn1/unborn/index.php (it is the article with this title: "8.3.2006 - Ίδρυση του Συλλόγου Προστασίας Αγέννητου Παιδιού Πτολεμαΐδος" (it appears without a NEW icon).
What should I change to make the icon appear here as well?
Also, one question: what is exactly the DATE_ARTICLE? The article_creation_date or the Last_Edit_date?
Your trick worked! I did in:
Code: Select all
$template_default["article"]["title_after"] = ' {D:{DATE_ARTICLE},30,new_icon1.gif} </span>';
(the NEW icon appears next to the title).
However the NEW icon does not appear next to the article title in the category: http://www.unborn.gr/unborn1/unborn/ind ... rentevents (it is the first article, the only one which appears with a summary)
What should I change so that the NEW icon is displayed in the article title when the category is displayed (both when the article is displayed with a summary and when it is displayed only in the list)?
Additionally, the NEW icon is not displayed when a list is displayed using the {NEWCATID:X:X}. See: http://www.unborn.gr/unborn1/unborn/index.php (it is the article with this title: "8.3.2006 - Ίδρυση του Συλλόγου Προστασίας Αγέννητου Παιδιού Πτολεμαΐδος" (it appears without a NEW icon).
What should I change to make the icon appear here as well?
Also, one question: what is exactly the DATE_ARTICLE? The article_creation_date or the Last_Edit_date?