News Flash Content Type [Updated 2.0.4]
UPDATED to version 2
Hi
I've updated the news flash content type to allow selection of whole article categories. Actually it is a completely new content type because the changes would cause all previous news flash contents to not work anymore.
Instructions and downloads: http://www.ikfrej.se/index.php?downloads
In the above example, all articles from the category with title "Content" plus two more articles will appear in the article listing generated by the news flash content part.
Cheers,
Jens
I've updated the news flash content type to allow selection of whole article categories. Actually it is a completely new content type because the changes would cause all previous news flash contents to not work anymore.
Instructions and downloads: http://www.ikfrej.se/index.php?downloads
In the above example, all articles from the category with title "Content" plus two more articles will appear in the article listing generated by the news flash content part.
Cheers,
Jens
Last edited by JensZ on Mon 19. Dec 2005, 16:53, edited 1 time in total.
Only Frold, Pappnase and OG have superpowers, they're the heroes
Nice update JensZ, many many many thanks, cool!
Cheers
Nice update JensZ, many many many thanks, cool!
Cheers
1.3 out, testing, testing...
Sponsoring 4 phpwcms Blog and Usermanagement
Sponsoring 4 phpwcms Blog and Usermanagement
At your service...
Kosse wrote:Only Frold, Pappnase and OG have superpowers, they're the heroes
Nice update JensZ, many many many thanks, cool!
Cheers
http://www.studmed.dk Portal for doctors and medical students in Denmark
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
Error using NewsFlash v2
Alright,
I uploaded the files and then carefully renamed the original files ".b4nf" and then replaced the .nf off of the ones that came with the zip file. I am currently using phpwcms 1.2.8 w/ patch C. The installation, properly put all the content part items in the interface, but now when I try to load the page, with or without the content part. I get this error.
To all you chewing over the solution, I thank you...peace
I uploaded the files and then carefully renamed the original files ".b4nf" and then replaced the .nf off of the ones that came with the zip file. I am currently using phpwcms 1.2.8 w/ patch C. The installation, properly put all the content part items in the interface, but now when I try to load the page, with or without the content part. I get this error.
Code: Select all
Fatal error: Cannot redeclare utf2html() (previously declared in /mnt/Target01/324460/324463/www.abraira.com/web/content/include/inc_front/front.func.inc.php:3030) in /mnt/Target01/324460/324463/www.abraira.com/web/content/include/inc_front/ext.func.inc.php on line 81
"The trick is living without an answer."
It seems like the function utf2html has been declared twice. Maybe the function has moved to a different module in 1.2.8? To resolve, remove utf2html() from front.func.inc.php. Alternatively, wrap this around the function:
Good luck!
Jens
Code: Select all
if(!function_exists("utf2html"))
{
function utf2html()
{
// ... body of function here
}
}
Jens
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
Still not quite there
I am still getting the error:
I went into the inclue/inc_front/front.func.inc.php file and found it reading like this:
I then changed it to this:
[/b]
Code: Select all
Fatal error: Cannot redeclare utf2html() (previously declared in /mnt/Target01/324460/324463/www.abraira.com/web/content/include/inc_front/front.func.inc.php:3031) in /mnt/Target01/324460/324463/www.abraira.com/web/content/include/inc_front/ext.func.inc.php on line 81
Code: Select all
// taken from http://www.php.net/manual/en/function.utf8-decode.php
// vpribish at shopping dot com, 10-Sep-2004 08:55
function utf2html($str) {
$ret = '';
$max = strlen($str);
$last = 0; // keeps the index of the last regular character
for ($i=0; $i < $max; $i++) {
$c = $str{$i};
$c1 = ord($c);
if ($c1>>5 == 6) { // 110x xxxx, 110 prefix for 2 bytes unicode
$ret .= substr($str, $last, $i-$last); // append all the regular characters we've passed
$c1 &= 31; // remove the 3 bit two bytes prefix
$c2 = ord($str{++$i}); // the next byte
$c2 &= 63; // remove the 2 bit trailing byte prefix
$c2 |= (($c1 & 3) << 6); // last 2 bits of c1 become first 2 of c2
$c1 >>= 2; // c1 shifts 2 to the right
$ret .= "&#" . ($c1 * 100 + $c2) . ";"; // this is the fastest string concatenation
$last = $i+1;
}
}
return $ret . substr($str, $last, $i); // append the last batch of regular characters
}
Code: Select all
// taken from http://www.php.net/manual/en/function.utf8-decode.php
// vpribish at shopping dot com, 10-Sep-2004 08:55
if(!function_exists("utf2html")) {
function utf2html($str) {
$ret = '';
$max = strlen($str);
$last = 0; // keeps the index of the last regular character
for ($i=0; $i < $max; $i++) {
$c = $str{$i};
$c1 = ord($c);
if ($c1>>5 == 6) { // 110x xxxx, 110 prefix for 2 bytes unicode
$ret .= substr($str, $last, $i-$last); // append all the regular characters we've passed
$c1 &= 31; // remove the 3 bit two bytes prefix
$c2 = ord($str{++$i}); // the next byte
$c2 &= 63; // remove the 2 bit trailing byte prefix
$c2 |= (($c1 & 3) << 6); // last 2 bits of c1 become first 2 of c2
$c1 >>= 2; // c1 shifts 2 to the right
$ret .= "&#" . ($c1 * 100 + $c2) . ";"; // this is the fastest string concatenation
$last = $i+1;
}
}
return $ret . substr($str, $last, $i); // append the last batch of regular characters
}
}
"The trick is living without an answer."
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
Upon further investigation...
Well since I didn't get a quick reply to my latest post, I went ahead and started to chisel away to see what pieces remain. First, the functions declared in your front.func.inc.php are already declared in version 1.2.8 in the ext.func.inc.php file in the same directory.
- is_date()
is_float_ex()
decode_entities()
utf2html()
Code: Select all
Fatal error: Call to undefined function: getimagecaption() in /mnt/Target01/324460/324463/www.abraira.com/web/content/include/inc_front/content.article.inc.php on line 155
"The trick is living without an answer."
It seems like Oliver has rearranged the front.func.inc.php totally in 1.2.8 and created a new file called ext.func.inc.php with all non-core code. What you need to do is to keep the original front.func.inc.php as is and merge the newsflash functions (get_newsflash_articles_data() and get_newsflash_article_list()) into ext.func.inc.php. I haven't tried this myself, but it should work.
I will upgrade newsflash for 1.2.8 as soon as I upgrade myself, which probably will not be until November or so.
Cheers,
Jens
I will upgrade newsflash for 1.2.8 as soon as I upgrade myself, which probably will not be until November or so.
Cheers,
Jens
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
Tried your suggestion...
Jenz,
Thank you for taking the time with your busy schedule. I tried your suggestion by copying both the (get_newsflash_articles_data() and get_newsflash_article_list() function into the ext.func.inc.php file. This is what the code looked like. I copied the function and put at the end of the document.
I didn't get a php error, but this is what my webpage looked like.
When I tried copying the code to the top of the document, that basically printed the entire ext.func.inc.php file onto the web page.
Thank you for taking the time with your busy schedule. I tried your suggestion by copying both the (get_newsflash_articles_data() and get_newsflash_article_list() function into the ext.func.inc.php file. This is what the code looked like. I copied the function and put at the end of the document.
Code: Select all
....
function getContentPartTopLink($param=0) {
global $template_default;
$toplink = '';
if($param) {
if($template_default["article"]["top_sign_before"].$template_default["article"]["top_sign_after"]) {
$toplink .= $template_default["article"]["top_sign_before"];
$toplink .= '<a href="#top">'.$template_default["article"]["top_sign"].'</a>';
$toplink .= $template_default["article"]["top_sign_after"];
} else{
$toplink .= '<br /><a href="#top">' . $template_default["article"]["top_sign"] . '</a>';
}
}
return $toplink;
}
function getContentPartAlias($crow) {
global $db;
$alias = unserialize($crow["acontent_form"]);
if(!empty($alias['alias_ID'])) {
$alias['alias_ID'] = intval($alias['alias_ID']);
$sql_alias = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_id=";
$sql_alias .= $alias['alias_ID'] . " AND acontent_trash=0 LIMIT 1";
if($alias_result = mysql_query($sql_alias, $db)) {
if($alias_row = mysql_fetch_assoc($alias_result)) {
if(empty($alias['alias_block'])) {
$alias_row['acontent_block'] = $crow['acontent_block'];
}
if(empty($alias['alias_spaces'])) {
$alias_row['acontent_before'] = $crow['acontent_before'];
$alias_row['acontent_after'] = $crow['acontent_after'];
}
if(empty($alias['alias_title'])) {
$alias_row['acontent_title'] = $crow['acontent_title'];
$alias_row['acontent_subtitle'] = $crow['acontent_subtitle'];
}
if(empty($alias['alias_toplink'])) {
$alias_row['acontent_top'] = $crow['acontent_top'];
}
$crow = $alias_row;
}
mysql_free_result($alias_result);
}
}
return $crow;
}
?>
// Jens for News Flash
// $article_list: comma-separated list of article IDs
// $dbcon: database connection
function get_newsflash_articles_data($article_list, $dbcon)
{
//returns the complete active and public article data as array (basic infos only)
//so it is reusable by many functions -> lower db access
$data = array();
$returnData = array();
$sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ";
$sql .= "WHERE article_id in (".$article_list.") ";
// VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
switch(VISIBLE_MODE) {
case 0: $sql .= " AND article_public=1 AND article_aktiv=1";
break;
case 1: $sql .= " AND article_uid=".$_SESSION["wcs_user_id"];
break;
//case 2: admin mode no additional neccessary
}
$sql .= " AND article_deleted=0 AND article_begin < NOW() AND article_end > NOW() ";
if($result = mysql_query($sql, $dbcon))
{
while($row = mysql_fetch_assoc($result))
{
$data[$row["article_id"]] = array(
"article_id" => $row["article_id"],
"article_cid" => $row["article_cid"],
"article_title" => $row["article_title"],
"article_subtitle" => $row["article_subtitle"],
"article_keyword" => $row["article_keyword"],
"article_summary" => $row["article_summary"],
"article_redirect" => $row["article_redirect"],
"article_date" => $row["article_date"],
"article_username" => $row["article_username"],
"article_sort" => $row["article_sort"],
"article_notitle" => $row["article_notitle"],
"article_created" => $row["article_created"],
"article_image" => unserialize($row["article_image"]),
"article_timeout" => $row["article_cache"],
"article_nosearch" => $row["article_nosearch"],
"article_nositemap" => $row["article_nositemap"],
"article_aliasid" => $row["article_aliasid"],
"article_headerdata"=> $row["article_headerdata"],
"article_morelink" => $row["article_morelink"]
);
// now check for article alias ID
if($row["article_aliasid"]) {
$aid = $row["article_id"];
$alias_sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ";
$alias_sql .= "WHERE article_deleted=0 AND article_id=".intval($row["article_aliasid"]);
if(!$row["article_headerdata"]) {
switch(VISIBLE_MODE) {
case 0: $alias_sql .= " AND article_public=1 AND article_aktiv=1";
break;
case 1: $alias_sql .= " AND article_uid=".$_SESSION["wcs_user_id"];
break;
}
$alias_sql .= " AND article_begin < NOW() AND article_end > NOW()";
}
$alias_sql .= " AND article_deleted=0 LIMIT 1";
if($alias_result = mysql_query($alias_sql, $dbcon)) {
if($alias_row = mysql_fetch_assoc($alias_result)) {
$data[$aid]["article_id"] = $alias_row["article_id"];
// use alias article header data
if(!$row["article_headerdata"]) {
$data[$aid]["article_title"] = $alias_row["article_title"];
$data[$aid]["article_subtitle"] = $alias_row["article_subtitle"];
$data[$aid]["article_keyword"] = $alias_row["article_keyword"];
$data[$aid]["article_summary"] = $alias_row["article_summary"];
$data[$aid]["article_redirect"] = $alias_row["article_redirect"];
$data[$aid]["article_date"] = $alias_row["article_date"];
$data[$aid]["article_image"] = unserialize($alias_row["article_image"]);
}
}
mysql_free_result($alias_result);
}
}
}
// reorder according to article list
$articleOrder = explode(",", $article_list);
foreach($articleOrder as $key => $value)
{
$returnData[$key] = $data[$value];
}
mysql_free_result($result);
}
return $returnData;
}
// -------------------------------------------------------------
// added by jens for newsflash v2
function get_newsflash_article_list($aList)
{
$s = "";
$newList = array();
if(!is_array($aList))
{
return $s;
}
foreach($aList as $key => $value)
{
$prefix = substr($value,0,1);
$id = intval(substr($value,1));
if($prefix == 'c') // category
{
// get order
$sql = "SELECT acat_order FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id = ".$id;
$result = mysql_query($sql, $GLOBALS['db']);
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
$ao = get_order_sort($row["acat_order"]);
// read from database
$sql = "SELECT article_id, article_cid, article_title FROM ".DB_PREPEND."phpwcms_article ";
$sql .= "WHERE article_cid=".$id." AND article_public = 1 AND article_aktiv = 1 AND ";
$sql .= "article_deleted=0 AND article_begin<NOW() AND article_end>NOW() ";
$sql .= "ORDER BY ".$ao[2];
if($result = mysql_query($sql, $GLOBALS['db']))
{
while($row = mysql_fetch_assoc($result))
{
if(!in_array($row["article_id"], $newList))
{
array_push($newList, $row["article_id"]);
}
}
mysql_free_result($result);
}
}
else if($prefix == 'a') // article
{
if(!in_array($id, $newList))
{
array_push($newList, substr($value,1));
}
}
}
$s = implode(",", $newList);
return $s;
}
?>
When I tried copying the code to the top of the document, that basically printed the entire ext.func.inc.php file onto the web page.
"The trick is living without an answer."
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
My bad....
sorry I am not very good at php and just now discovered the ?> misplaced in my script.
"The trick is living without an answer."
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
almost working (rig didn't work)
Alright this whole issue would probably never have surfaced if the Newsflash Content Part would have done its thing. (Or at least how I thought it would work.) I created a new block called ARTICLE_ICON that would hold a designated icon for each article that I created. The idea was to have the Newsflash component than display their respective icons for each article.
Two outcomes to different methods:
Content Part - This method yielded a listing of all the articles but with the same icon. The listing template was just one line of code: {ARTICLE_ICON}.
Replacement tag - I put the replacement to show c10 (category 10) with the same template. This created an error:
I am running on 1.2.8 (w/ G Patch) release. This is not an upgrade.
sorry to rain on the parade (or maybe its just raining over here)
thanks for your help y'all
Two outcomes to different methods:
Content Part - This method yielded a listing of all the articles but with the same icon. The listing template was just one line of code: {ARTICLE_ICON}.
Replacement tag - I put the replacement to show c10 (category 10) with the same template. This created an error:
Code: Select all
Fatal error: Call to undefined function: get_newsflash_article_list() in /home/content/s/p/o/spotlightla/html/phpwcms_template/inc_script/frontend_render/newsflash.php on line 33
sorry to rain on the parade (or maybe its just raining over here)
thanks for your help y'all
"The trick is living without an answer."
- anthony.abraira
- Posts: 99
- Joined: Sun 11. Sep 2005, 07:42
- Location: Mars Hill, NC
- Contact:
now its just the replacement tag
Please disregard the first issue. Totally forgot about the summary image. (Which takes the place of my ARTICLE ICON idea....now the only problem is with the replacement tag....same error
"The trick is living without an answer."