WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: fienieg on February 27, 2005, 06:50:48 PM

Title: Code Snippet: Display news items, anywhere
Post by: fienieg on February 27, 2005, 06:50:48 PM
I made very rough code, that makes a listing of a specific group(id)
With the option of setting a "max results", and order them by date added. etc..

Just read the code, play with it. Refine it, restyle it.

Have fun..

Code: [Select]

<!-- NEWS READER -->
<?php
$group 
0// Specify the Group&#40;id&#41; you want to read the news from

global $database;

$query "SELECT post_id,title,group_id,link 
  FROM "
.TABLE_PREFIX."mod_news_posts
          WHERE group_id = 
$group
          ORDER BY posted_when DESC 
  LIMIT 0, 5;"
// This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
  // The first number defines the starting point, and the second the max/end of the results
$error mysql_error&#40;&#41;;
if &#40;!$result = mysql_query&#40;$query&#41;&#41; &#123;
    
print "$error";
exit;
&#125;

while&#40;$data = mysql_fetch_object&#40;$result&#41;&#41;&#123;
  
$title $data->title;
  
$id $data->post_id;
  
$link $data->link?>

<p>
<a href="<?php echo WB_URL?><?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>
</p>
<?php
&
#125;
?>

<!-- END NEWS READER -->
Title: Code Snippet: Display news items, anywhere
Post by: mightofnight on February 28, 2005, 10:27:17 PM
Good Idea!
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 07, 2005, 12:19:55 PM
I would LOVE to use this snippet, but I don't know how :-(

When I copy the code into a Code module, it doesn't work. So I guess that is not the way it should be used... What is the right way to use this snippet?

And how do I have to use the Code module anyway? Can you just paste any HTML, JS, or PHP into it? I guess not, but I don't know how to use it properly...
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 07, 2005, 02:10:44 PM
just place the snippet into your template... any where you want to display the latest news items...
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 07, 2005, 02:14:53 PM
So no code page thing....
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 07, 2005, 03:36:39 PM
OK, thanks. So snippets are template based, not page based? Is it possible to convert a snippet to a module? That way you can add it to pages without having to create another template for it, if you don't want to have it on every page.
Title: YES!!!!
Post by: Argos on March 07, 2005, 03:39:58 PM
Very cool!! I tried it, and it works like a charm. I am very happy!!!  :D  :D
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 08, 2005, 02:00:19 AM
Hm... I'm still happy, but I noticed a small problem. The listing in the snippet is chronological, in order of input. When I change the order of the items in the backend, the order on the news page changes too, so that is correct. But the order of the snippet listing isn't affected by the back end change. Can this be changed? I know the snippet listing is a light version of the normal news listing, but I would like it to be just bit heavier, so that it listens to changes in the back end...

You can see it on http://www.bereikbaarheid.nl/cms.
This is a site I am working on for a client. It is not operational yet, and a number of things are not finished yet. But the news listing is working. It's a Dutch site, but that shouldn't be problem to see what mean.
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 08, 2005, 07:28:00 PM
Quote from: Argos
Hm... I'm still happy, but I noticed a small problem. The listing in the snippet is chronological, in order of input. When I change the order of the items in the backend, the order on the news page changes too, so that is correct. But the order of the snippet listing isn't affected by the back end change. Can this be changed? I know the snippet listing is a light version of the normal news listing, but I would like it to be just bit heavier, so that it listens to changes in the back end...

You can see it on http://www.bereikbaarheid.nl/cms.
This is a site I am working on for a client. It is not operational yet, and a number of things are not finished yet. But the news listing is working. It's a Dutch site, but that shouldn't be problem to see what mean.


Damn that template is looking nice... it's a beauty...
(and i'm dutch so i can read it ;))

I made the news script, so all news items added to the database, and only the latest 5 are displayed... you can also make it, replacing, ORDER BY posted_when by ORDER BY position, then it's affected by the admin back end.

But this is just a little snippet i'll try to build one with more options...
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 08, 2005, 08:23:55 PM
Fienieg, you made my day by saying nice things (thanks!) and solving my little problem. Great, I appreciate it!!

Most of the times I can tweak scripts here and there, but I don't really understand why it works or not. Creating something myself is out of my league. What I do is based on limited insight, and much trial and error. I don't have real knowledge and skills, which is annoying. I really should learn at least the basics of PHP... If only I had the time :-(

I will create some templates in the near future to give something back to the community. I have some designs from projects that didn't make it to the end, and some tryouts for myself. I can customize them into WSB templates.

By the way, your News script is in fact very useful, and I use it not only for posting news and events, but also as a FAQ. The FAQ Baker module is not very useful I think, because it's just a long list of entries. That's only useful if you have only a few questions. Your News module is perfectly usable for a FAQ that can grow larger over time. If you keep updating it, it will be a very powerful module indeed!
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 09, 2005, 12:51:11 AM
your welcome...

we all contribute to WB, you may send me your works, and maybe i can turn them into some templates  :wink:
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 09, 2005, 03:41:32 PM
Well, I will create them myself because they are not generally usable yet. They refer to clients, aren't really finished yet, or dont have the proper quality.

But you can also take a look at [url removed becasue no longer in use] where I sell templates memberships. If you can pick a few (no, not all!) that you feel may be usable as a basis for WSB templates, please let me know and I'll send them to you. But only for use as WSB templates that will be published freely! And I want my name/website mentioned in the html source.

By the way, I did not create these templates myself. Half of them were created by someone for me exclusively, and the other half were made by someone who I have made a template swapping deal with.
Only this one I created myself: [url removed becasue no longer in use] which I will transform into a WSB templaet myself.
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 09, 2005, 03:52:23 PM
yeah i only  :lol:  publish templates freely... and i leave name in the credits.
I'll just mention you in the credits section

these templates
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=108
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=81
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=80

these 3 a could make into templates, for general use...
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 09, 2005, 04:01:44 PM
PM'd you...
Title: Code Snippet: Display news items, anywhere
Post by: Stefan on March 15, 2005, 12:33:31 PM
Quote from: Argos

You can see it on http://www.bereikbaarheid.nl/cms


Do I see it correctly that you have written a Javascript menu that uses the WebsiteBaker page tree? If so, would you be willing to release it to the general public?
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 15, 2005, 01:27:39 PM
Quote from: Stefan
Quote from: Argos

You can see it on http://www.bereikbaarheid.nl/cms


Do I see it correctly that you have written a Javascript menu that uses the WebsiteBaker page tree? If so, would you be willing to release it to the general public?


I wish I could do that :-)
No, it's just a seperate DHTML menu I included in the template. All links must be made manually. In this case that is okey, because the client doesn't need to create pages or change the structure of the site. Only modify existing pages. And if he needs to have other pages, he can create them, but I have to add them to the menu...

Too bad it isn't a dynamically created menu, ain't it? :-)
Title: Code Snippet: Display news items, anywhere
Post by: Stefan on March 15, 2005, 02:22:12 PM
Yeah, too bad really.
I've had a look at your javascript code - quite confusing with all the numbers, spacers and what not.
To make an automatically maintained menu, it is necessary to have a way of writing the entries without any individual hacks. So say, I give you a menu structure:
Top1
---T1Sub1
---T1Sub2
Top2
---T2Sub1
---T2Sub2
can you (manually) make a nice-looking dhtml menu out of that without any further information, hacks, etc. No tweaking allowed!
If so, it's no problem to make the transition to a true WB dynamical menu. I've just not looked into dhtml menus at all, otherwise I would've done it already.
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 15, 2005, 02:35:19 PM
Quote from: Stefan
Yeah, too bad really.
I've had a look at your javascript code - quite confusing with all the numbers, spacers and what not.
To make an automatically maintained menu, it is necessary to have a way of writing the entries without any individual hacks. So say, I give you a menu structure:
Top1
---T1Sub1
---T1Sub2
Top2
---T2Sub1
---T2Sub2
can you (manually) make a nice-looking dhtml menu out of that without any further information, hacks, etc. No tweaking allowed!
If so, it's no problem to make the transition to a true WB dynamical menu. I've just not looked into dhtml menus at all, otherwise I would've done it already.


Yeah, I know the code looks terribly complicated, but it is generated by the program I use: http://www.sothink.com/webtools/dhtmlmenu/index.htm

Actually, it has the built-in option of creating menu's dynamically with PHP or other methods, but I am not a programmer so I don't really understand how I should do that :cry:  

I like this software very much, I use it a lot. It's powerful and very user friendly, using a drop and drag, WYSIWYG way of creating menus. Rather cheap too: only 35 dollars. Maybe you could check it out...
Title: Code Snippet: Display news items, anywhere
Post by: Stefan on March 15, 2005, 02:37:25 PM
Well, it's not a solution for a standard WB dynamical menu if it's not free, but still, thanks for the tip.
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 15, 2005, 02:48:27 PM
Ah! I didn't realize you were looking for a free script to include in WSB :-)

There are free dhtml menu available though, but I haven't tried them.
I've got http://www.dynamicdrive.com/ in my bookmarks. They have some I know. And Google knows some as well :-) http://www.google.nl/search?hl=nl&q=free+dhtml+menu&lr=
Title: Code Snippet: Display news items, anywhere
Post by: Stefan on March 15, 2005, 02:53:30 PM
It's just that I don't have time to play around with it. Something is always the problem - either its compatibility or looks or whatever.
I was hoping you had found a good one that could be used. I would have just written the php part, which should be no big deal.
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 15, 2005, 03:14:55 PM
i also got one or two of those javascripts...
i'm fine tunning them...
Title: Code Snippet: Display news items, anywhere
Post by: Craig.Rodway on March 26, 2005, 02:41:09 AM
Just a little update to the snippet...

If you want to put it into a Code section - you can, use this code below:

Code: [Select]
$group = 2; // Specify the Group(id) you want to read the news from

global $database;

$query = "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 5;";

/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
  print "$error";
  exit;
}

while($data = mysql_fetch_object($result)){
  $title = $data->title;
  $id = $data->post_id;
  $link = $data->link;
  echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
}


It simply removes the <?php and ?> tags, and echos the link properly :)
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 26, 2005, 05:34:30 AM
thanks craig, but some level of understanding of WB is needed with the code snippets...  :wink:  (dont make to easie for them  :P  :twisted:  :roll: )
Title: Code Snippet: Display news items, anywhere
Post by: Argos on March 26, 2005, 11:36:04 AM
Quote from: fienieg
thanks craig, but some level of understanding of WB is needed with the code snippets...  :wink:  (dont make to easie for them  :P  :twisted:  :roll: )


What do you mean by that?  :?  I tried this code snippet, and it works allright.
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on March 26, 2005, 01:46:16 PM
Quote from: Argos
What do you mean by that?  :?  I tried this code snippet, and it works allright.


In the code page they don't allow <? and ?>, so if you want to use it, you need to use the echo command, in stead of using a php break, and then adding html!
Title: generated link paths wrong
Post by: valerie on May 23, 2005, 07:10:56 AM
Hi. I'm trying to learn about using code snippets. Maybe you can help me with this: I inserted the code into the template and it worked, but the links it generates are missing the pages folder:

I get: http://www.sweetike.com/wbaker/wb/posts/albuquerque-here-we-come2.php

Not: http://www.sweetike.com/wbaker/wb/pages/posts/albuquerque-here-we-come2.php

Can you tell me what to insert into the code to correct this?

Thanks!
Title: Code Snippet: Display news items, anywhere
Post by: fienieg on May 23, 2005, 01:37:07 PM
Just replace this
Code: [Select]
<a href="<?php echo WB_URL?><?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>

With:
Code: [Select]

<a href="<?php echo WB_URL?>/pages/<?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>
Title: Re: Code Snippet: Display news items, anywhere
Post by: jonathanbb on October 13, 2005, 02:51:48 PM
Hi

I am trying to use this snippet in my template I get a Parse Error for this line

if &#40;!$result = mysql_query&#40;$query&#41;&#41; &#123;

and have no clue why.

To be truth full I dont have a clue what that line does either so hope someone out there can help me.

Thanks
Jonathan
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on October 13, 2005, 03:05:22 PM
if &#40;!$result = mysql_query&#40;$query&#41;&#41; &#123;


There are display codes in them, it is an old post, some leftovers from the forum migration.

Try the other one, posted by Craig.Rodway that one will work.


Happy Baking!
John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 18, 2005, 10:07:51 AM
Hi all!

Now i tryed, to use, it, and i can get it to work, in the template (exept, when i press the link, it says, "the page can not be found"....
Then i tryed to use it on a page, as i want - but there i only get this message on the page

 (title; $id = $data->post_id; $link = $data->link; echo '
'.$title.'

';}#125; ?> )  

that what i can see on the page i put the code in....


this is the code i used:
<!-- NEWS READER -->
<?php
$group = 0; // Specify the Group&#40;id&#41; you want to read the news from

global $database;

$query = "SELECT post_id,title,group_id,link
        FROM ".TABLE_PREFIX."mod_news_posts
          WHERE group_id = $group
          ORDER BY posted_when DESC
        LIMIT 0, 5;"; // This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
        // The first number defines the starting point, and the second the max/end of the results
$error = mysql_error();
if (!$result = mysql_query($query)) {
 print "$error";
 exit;
}

while($data = mysql_fetch_object($result)){
 $title = $data->title;
 $id = $data->post_id;
 $link = $data->link;
 echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';}#125;
?>
<!-- END NEWS READER -->


how do i set the code correct onto a page?..... please help, someone :? :|
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 23, 2005, 08:35:46 PM
This is the code you need: you can place it in your template or you can place it in a code section


Code: [Select]
$group = 2; // Specify the Group(id) you want to read the news from

global $database;

$query = "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 5;";

/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
 print "$error";
 exit;
}

while($data = mysql_fetch_object($result)){
 $title = $data->title;
 $id = $data->post_id;
 $link = $data->link;
 echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
}

John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 24, 2005, 10:12:15 AM
hi again,

i must be missing something, because when i put it in the code page... nothing happens, the page is just empty??
is there a special way to put it in the code?
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 24, 2005, 02:24:52 PM
did you check the group?????


Make sure the group is the same you have, or it won't show anything ;)

John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 24, 2005, 02:38:40 PM
hi agin.... thanks.... i set group to "0".... and it worked fine..... thank you......

now i just have to make it look like i want... thank you again.... if i want to change it, i should change in this same code, right?
i want it to show the "short" text under the title also.....

well... just 1. problem... it doesn´t find the pages.. it looks for a folder called post, put it inside the pages folder, but i don´t know where to set the /pages/ in the code?
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 24, 2005, 03:34:15 PM
change: echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
to : echo '<p><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
or :echo '<p><a href="'.WB_URL.'pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';

don't have time to test ;)



John

Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 24, 2005, 03:41:03 PM
Hi again.. and thanks...

this is the one that worked, thanks :-D


echo '<p><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
Title: Re: Code Snippet: Display news items, anywhere
Post by: ictcafe on November 26, 2005, 03:31:29 PM
I've tweaked a little the code, but two questions:
1. how get i the short description under the title
2. how do i get an unsorted list from all the items?

Code: [Select]
global $database;

$query = "SELECT post_id,title,group_id,page_id,link,short FROM ".TABLE_PREFIX."mod_news_posts WHERE page_id = $page_id ORDER BY post_id DESC LIMIT 0, 5;";

/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

echo "Last 5 news posts:"."<br>";

while($data = mysql_fetch_object($result)){
$title = $data->title;
$page = $data->page_id;
$id = $data->post_id;
$link = $data->link;
$short = $data->short;

echo '* <a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></br>';

}
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 26, 2005, 06:12:41 PM
Fetch the stuff you need from the database
You need content_short (look at table mod_news_post) for all the fields

The <ul><li> ... </li></ul>, just add it to the output:

Something like this:
Code: [Select]
global $database;

$query = "SELECT post_id,title,group_id,content_short, page_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE page_id = $page_id ORDER BY post_id DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

echo "Last 5 news posts:"."<br>";
echo "<ul>"; // start of the loop

while($data = mysql_fetch_object($result)){
$title = $data->title;
$page = $data->page_id;
$id = $data->post_id;
$link = $data->link;
$short = $data->short_content;

echo '<li><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a>'.$short.'</li>'; // the loop

}
echo "</ul>"; // end of the loop
Didn't test it!

John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 28, 2005, 01:01:26 PM
hi all!

i tryed to change the code a bit, and so far, so good!

BUT... i want it to show the pictures that are shown along the "short text too", but i cant fint the id, in the database, does anyone know where the pictures goes in the database.

This i my code for now:

$group = 0; // Specify the Group(id) you want to read the news from

global $database;

$query = "SELECT post_id,title,short,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 10;";

/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}
while($data = mysql_fetch_object($result)){
$title = $data->title;
$short= $data->short;
$id = $data->post_id;
$link = $data->link;
echo '<br />';
echo '<table width=100%>';
echo '<tr><td bgcolor=#e7e7e7><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></td></tr>';
echo '<tr><td>'.$short.'</td></tr>';
echo '</table>';
}


Plesase any help wanted?
i know where to put it in the code,just can´t find it in the mysql database???
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 28, 2005, 01:46:39 PM
Doesn't seem to be in the database.


module/news/view.php reveals:
Code: [Select]
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
  $groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
} else {
  $groups[$group_id]['image'] = '';
}

So something like this might work (mind you , I had no time to test it!!)
Code: [Select]
$group = 0; // Specify the Group(id) you want to read the news from

global $database;

$query = "SELECT post_id,title,short,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 10;";

/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}
while($data = mysql_fetch_object($result)){
$title = $data->title;
$short= $data->short;
$id = $data->post_id;
$link = $data->link;
$group_id = $data->group_id;
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
  $picture = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
} else {
  $picture = '';
}

echo '<br />';
echo '<table width=100%>';
echo '<tr><td colspan=2 bgcolor=#e7e7e7><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></td></tr>';
echo '<tr><td>'.$picture.'</td><td>'.$short.'</td></tr>';
echo '</table>';
}

You could change the  $picture = ''; to a NoImage picture with:
  $picture = WB_URL.MEDIA_DIRECT ORY.'/.news/noimage.jpg';

Happy baking,
John
Title: Re: Code Snippet: Display news items, anywhere
Post by: restonian on November 28, 2005, 07:34:40 PM
I noticed that a few posts back there was a post including code that didn't have a group id defined inside it, i tried this myself, and it displayed nothing. Not a sausage.

Is it possible to have the latest news stories globally over every category?

If so what do i alter?
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 28, 2005, 11:29:20 PM
Yes it is possible, rather easy,

take out the test on $group in the query

or take a look at this one:
http://forum.WebsiteBaker.org/index.php/topic,1851.msg11398.html#msg11398

or try this one:
Code: [Select]
global $database;
$query = "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts ORDER BY position DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

while($data = mysql_fetch_object($result)){
$title = $data->title;
$id = $data->post_id;
$link = $data->link;
echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
}



Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on November 29, 2005, 12:40:54 PM
Hi i haven´t got the image working yet, but i´m still trying to work on that!

for now i have used the snippet, with group=0

but now a have on page (sport) with four subpages (football, hockey, tennis, else)
How can i make the snippet work so it just shows these four subpages... how can i find what group they are, i can just find page_id, and thats different for every page???
Title: Re: Code Snippet: Display news items, anywhere
Post by: restonian on November 29, 2005, 07:12:48 PM
Magic!

Cheers John.
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on November 29, 2005, 07:40:44 PM
@babsy,

This snippet only will show news posts
So if your posts are divided among those four pages testing for the pageid is the obvious thing to do.
Code: [Select]
global $database;
$get_page = 1; // change to your page_id you need

$query = "SELECT post_id, title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE page_id=$get_page ORDER BY position DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

while($data = mysql_fetch_object($result)){
$title = $data->title;
$id = $data->post_id;
$link = $data->link;
echo '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
}
The fields you can choose from are:
post_id, section_id, page_id, group_id, active, position,
title, link, content_short, content_long, commenting, posted_when, posted_by

phpmyadmin shows you that in a jiffy ;)

Happy baking,
John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 06, 2005, 02:06:24 PM
Hi everyone, i´m still trying to get this picture to work... but i just can´t find the picture folder anywhere - does any off you know the path to the pictures in "short text" in the news, my code for now looks like this:

$group = 0; // Specify the Group(id) you want to read the news from
global $database;
$query = "SELECT post_id,title,short,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 10;";
/*
This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}
while($data = mysql_fetch_object($result)){
$title = $data->title;
$short= $data->short;
$id = $data->post_id;
$link = $data->link;
$group_id = $data->group_id;
if(file_exists(WB_PATH.MEDIA_DIREC TORY.'/.news/image'.$group_id.'.jpg')) {
  $picture = WB_URL.MEDIA_DIRECT ORY.'/.news/noimage.jpg';
} else {
  $picture = '';
}


echo '<br />';
echo '<table width=100%>';
echo '<tr><td bgcolor=#e7e7e7><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a></td></tr>';
echo '<tr><td>'.$picture.'</td><td>'.$short.'</td></tr>';
echo '</table>';
}

But it just leaves an empty hole.... try take a look at this!
http://www.kjolurin.com
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on December 06, 2005, 03:51:40 PM
I see pictures on that page, looks like a bowling ally?

John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 06, 2005, 03:58:10 PM
hi, and sorry

i forgot, i had set, the page to "hidden" now you should see it right!

www.kjolurin.com
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on December 06, 2005, 04:42:58 PM
Did you look at your source of that page?

Code: [Select]
<a href="http://www.kjolurin.com/pages//posts/rrrrrrrrrrrrrrrrrrrr146.php">rrrrrrrrrrrrrrrrrrrr</a></td></tr><tr><td></td><td><p><img height=\"73\" hspace=\"5\" src=\"/media/Image/bowla.jpg\" width=\"142\" align=\"left\" border=\"1\" /><img height=\"1\" src=\"/\"//\"/media/Image/bowla.jpg//\"/\"\" width=\"1\" border=\"0\" /><br /><img style=\"\"WIDTH: \" height=\"1\" src=\"/\"/media/Image/bowla.jpg/\"\" width=\"1\" border=\"0\" />Doesn't look all to good to me

The images should come from the /media/.news directory! Not from /media/Image ....

I searched the source of your page for /media/.news nothing found!


In your posted code, this bit:
Code: [Select]
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
  $picture = WB_URL.MEDIA_DIRECTORY.'/.news/noimage.jpg';
} else {
  $picture = '';
}
If the picture exists, set picture to noimage.jpg or to nothing?
Maybe change to following:
Code: [Select]
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
  $picture = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
} else {
  $picture = '';
}
So if the picture exists it will get the url to the picture.

PS, The pictures for groups needs to be upoloaded first!
admin -> pages -> the page with news -> add groups (or modify group)-> image!!!!!!!!!


John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 06, 2005, 04:47:05 PM
hi and thanks... ill try this tomorrow when i´ll get back to work

but why does the sorce look like that?? and you said "Doesn't look all to good to me"
can i change it, so it looks more "normal"?
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on December 06, 2005, 07:12:14 PM
all the " are addslashed, ie, there are too many \ (backslashes)
<img height=\"73\" hspace=\"5\" should be
<img height="73" hspace="5" in html

John
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 07, 2005, 03:02:51 PM
hi John

please could you explain what you mean by this

"PS, The pictures for groups needs to be upoloaded first!
admin -> pages -> the page with news -> add groups (or modify group)-> image!!!"

When i have set pictures in, yet, i´ve just been putting them next to the text in both short and long text!
Title: Re: Code Snippet: Display news items, anywhere
Post by: pcwacht on December 07, 2005, 04:52:49 PM
This snippet will only show the group pictures, not the wysiyg added pictures.
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 08, 2005, 10:53:55 AM
hi again..

the group picture is´nt working, i can´t choose any picture, without getting an error!

but it is the wysiwig picture i wanted to show, but i thats impossible :|

but thanks for your help

Title: Re: Code Snippet: Display news items, anywhere
Post by: mangione on January 09, 2006, 03:53:54 PM
HI, i think you mean, that you wanna show the wysiwyg images also in the function where you get the last items and display it anywhere. I always had the problem, that the path from my images was wrong.

The plan was, to open the last newsitem in the "long" version and display the older news on the bottom. I used the following code:

--------- insert in a code page ----------

// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=10;

// Specify read more text
$readmore = "Weiterlesen";       

// Specify Older news text
$oldernews = "Older news";       

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}




// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // x
  $data = $result->fetchRow() ;    // get news item
$long=stripslashes($data['long']); //clear up the images path
  echo '<table width=100%>';
  echo '<tr><td width=100%><h1>'.$data['title'].'</h1></td></tr>';
echo '<tr><td>'.$long.'</td></tr>'; //view the long-version of the news
  echo '<tr><td></td><td></td></tr>';
  echo '</table>';
}

   // Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=0;

// Specify read more text
$readmore = "Artikel lesen";       

// Specify Older news text
$oldernews = "weitere Einträge";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 1, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // at least 2 needed for 2 news items
  $data2 = $result->fetchRow() ;    // get left item
  $data3 = $result->fetchRow() ;    // get left item
  $data4 = $result->fetchRow() ;    // get left item
  $data5 = $result->fetchRow() ;    // get left item
  $data6 = $result->fetchRow() ;    // get left item
  $data7 = $result->fetchRow() ;    // get left item
  $data8 = $result->fetchRow() ;    // get left item
  $data9 = $result->fetchRow() ;    // get left item
  $data10 = $result->fetchRow() ;    // get left item
  echo '<table class="newsoverview" width=100%>';
echo '<tr><td width="100%"><b>weitere News</b></td></tr>';
  echo '<tr><td width=100%><li><a href='.WB_URL.PAGES_DIREC TORY.$data2['link'].PAGE_EXTENSION.'>'.$data2['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href='.WB_URL.PAGES_DIREC TORY.$data3['link'].PAGE_EXTENSION.'>'.$data3['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data4['link'].PAGE_EXTENSION.'">'.$data4['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data5['link'].PAGE_EXTENSION.'">'.$data5['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data6['link'].PAGE_EXTENSION.'">'.$data6['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data7['link'].PAGE_EXTENSION.'">'.$data7['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data8['link'].PAGE_EXTENSION.'">'.$data8['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data9['link'].PAGE_EXTENSION.'">'.$data9['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data10['link'].PAGE_EXTENSION.'">'.$data10['title'].'</a></td></tr>';
  echo '</table>';
}
Title: Re: Code Snippet: Display news items, anywhere
Post by: artwebbo on March 24, 2006, 12:19:56 PM
Hi,

everything works perfect but I'm not a php coder and I have a little problem about how to impelement this...

I want to display news from mostly every news groups without one group on the other subpage.
How to put it in code?


thanks for helping,
Ewa

Title: Get Some Settings
Post by: gokcer on May 24, 2006, 07:28:22 PM
I've modified this code for my needs. You can specify the columns, last post limit, "active or not" from that pages "news settings" in the administration panel of wb without changing anything in the code. You must only specify the page_id of news page. This code is available with a "modified a lot" version of wb :). Some of the variables may not be available with standart (not much modified) versions. But maybe you can make available by modifying or deleting some codes. For example my link creation codes are different so I use only ".$link." in the "href"s. But the standart link code is ".WB_URL.'/pages/'.$link.PAGE_EXTENSION."

Place this code in your template file where you want to display the latest news:

Code: [Select]



<table width="100%" height="0%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
<?php 
define
(&#39;yenisatir&#39;, &#39;</tr><tr>&#39;); // yenisatir means new row
global $database;
$get_page 4// insert page_id here

$query_settings $database->query("SELECT posts_per_page FROM ".TABLE_PREFIX."mod_news_settings WHERE page_id=$get_page");
$fetch_settings $query_settings->fetchRow();
$latest $fetch_settings[&#39;posts_per_page&#39;]; // this calls the standard wb&#39;s post per page setting. So you can change latest news quantity by only changing your post per page setting. So, the quantities of post per page and latest news will be same.

$query "SELECT ".TABLE_PREFIX."mod_news_posts.post_id,".TABLE_PREFIX."mod_news_posts.short,".TABLE_PREFIX."mod_news_posts.title,".TABLE_PREFIX."mod_news_posts.link,".TABLE_PREFIX."mod_news_settings.num_cols FROM ".TABLE_PREFIX."mod_news_posts,".TABLE_PREFIX."mod_news_settings WHERE ".TABLE_PREFIX."mod_news_posts.page_id=$get_page AND ".TABLE_PREFIX."mod_news_posts.active=1 AND ".TABLE_PREFIX."mod_news_settings.page_id=$get_page ORDER BY position DESC LIMIT 0, $latest;";
// If you want to make different the quantities of post per page and latest news, replace "$latest" with a number above to specify the latest news quantity

$error mysql_error();
if (!
$result mysql_query($query)) {
print 
"$error";
exit;
}

$counter 0;
while(
$data mysql_fetch_object($result))
{
$title $data->title;
$short $data->short;
$id $data->post_id;
$link $data->link;
$num_cols $data->num_cols
echo stripslashes(&#39;<td class="haber" align="left" valign="top"><div style="padding-bottom: 1px; font-weight: bold;" ><b><a href="&#39;.$link.&#39;">&#39;.$title.&#39;</a></b></div>&#39;.$short.&#39;</td>&#39;); // If you didn&#39;t modified your WB to work with "safe mode on" (in other words if you are using default WB), replace .link. with .WB_URL.&#39;/pages/&#39;.$link.PAGE_EXTENSION.
$counter $counter+1;
if($counter == $num_cols// I&#39;ve added a column setting in my news module similiar to gallery module&#39;s column setting. I can specify my column quantity from news&#39; settings and latest news gets the number from there. If you didn&#39;t add (in other words if you are using default WB) replace $num_cols with a number to specify a column quantity
{
echo yenisatir;
$counter 0;
}
}
?>

  </tr></table>




good luck...
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 09, 2006, 02:42:49 PM
hi... i know this is a long time, since this subject was in use!

but i just can´t get it to work right!

i use this code.. in my template:

___________________ _______________
Code: [Select]
<?php
global $database;
$query "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts ORDER BY position DESC LIMIT 0, 5;";

$error mysql_error();
if (!
$result mysql_query($query)) {
print 
"$error";
exit;
}

while(
$data mysql_fetch_object($result)){
$title $data->title;
$id $data->post_id;
$link $data->link;
echo &
#39;<font class="nyttlink"><a href="&#39;.WB_URL.$link.PAGE_EXTENSION.&#39;">&#39;.$title.&#39;</font><br /><br /></a>&#39;;
}
?>
___________________ _________________

it works.. fine, until... when i press on the news... displayed.. it just says this:

[an error occurred while processing this directive] The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page  about the error. [an error occurred while processing this directive]

anyone know why  :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on October 09, 2006, 07:05:04 PM
I just tested the exact script, works fine here.

Have a look into my Templates "Snakeskin", Metalslabs" and "Molten Lava", they have this functionality implemented.

Maybe as a test, install them and try if they do work, just to make shure, that it's not a server issue.

Also try with a simple testpost (simple name like "test") to see if this works.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 09, 2006, 08:55:12 PM
thx... so far so good!!

but, i think i have another problems, but its not in the code i think!

because.... check it out http://klaknav.sudurras.com

now the code works... and the news.... exept when i press on read more...

the top header of my template goes away  :?

really weird!... 
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on October 09, 2006, 09:08:44 PM
but that is the template ... cause the URL:

Quote
http://klaknav.sudurras.com/pages/templates/round/top1_2.jpg

can not work.

Rework your template (have a look at the tutorial in the WIKI for the template path).

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 09, 2006, 09:10:18 PM
thanks..... i will... :-)

UPDATE:... works like a charm now!  :-D so thx again!!

but i could´nt find the exact image path in the template tutorial!??
but i just downoaded another template and took it from there, (don´t know why i didn´t think of that right away  :| )

so if anyone else (well a newbie i guess  :-D) is looking, this was it:

<td><img src="<?php echo TEMPLATE_DIR; ?>/top1_2.jpg" alt="" height="30" width="700" border="0" /></td>

so thanks again...
now everythink is working.. so far so good..

actually i would love to build some template for wb, now i think i can start on that  :wink:
Title: Re: Code Snippet: Display news items, anywhere
Post by: Bramus on December 20, 2006, 09:05:50 AM
Some one made me this piece of code also some time ago. Maybe it is usefull for anyone here. I have translated some things into dutch, but to edit it, that should be real easy. You can enter the max of news items to show and from what group or just all the news groups.

As i said IT IS NOT MADE BY ME! I respect this work and just want to share it with you. Some one posted it already some time for me, can't remember if it was by mail or here.

Example --> www.cavaliershelden.nl (http://www.cavaliershelden.nl)

Code: [Select]
// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 2;       

// Specify number of newsitems                       
$limit=4;

// Specify read more text
$readmore = "Lees Verder";       

// Specify Older news text
$oldernews = "Oude items";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // at least 2 needed for 2 news items
  $data = $result->fetchRow() ;    // get left item
  $data2 = $result->fetchRow() ;  // get right item
  echo '<table width=100% border=0>';
  echo '<tr><td width=50%><b>'.$data['title'].'</b></td><td></td></tr>';
  echo '<tr><td>'.$data['content_short'].'</td><td></td></tr>';
  echo '<tr><td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td width=50%><b>'.$data2['title'].'</b></td></tr>';
  echo '<tr><td></td><td>'.$data2['content_short'].'</td></tr>';
  echo '<tr><td></td><td><a href="'.WB_URL.PAGES_DIRECTORY.$data2['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td></tr>';
  echo '</table>';
}

// Next show the rest
if ($total>2) {                                // are there any left?
echo '<br><br><table><tr><td colspan=2><b>'.$oldernews.'</b></td></tr>';
echo '<tr><td>Datum</td><td>Onderwerp</td></tr>';
while ($data = $result->fetchRow()) {
  echo '<tr><td>'.strftime( "%d-%m-%Y",$data['posted_when']).'</td>';
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$data['title'].'</a></td></tr>';
}
echo '</table>';
}

This can be used in a CODE section on a page.
Title: Re: Code Snippet: Display news items, anywhere
Post by: beeswax on December 27, 2006, 02:16:26 PM
I'm really new to WB, and I've tried to follow this thread and implement it, but so far with no luck.
Earlier in this thread sowmone refers to the template Wiki, where is it? I don't know how to insert code into a template (I tried, but didn't get very far), will I find this on the Wiki?
When it comes to code(ing) I'm very, very, very noob.
beeswax
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on December 27, 2006, 03:12:54 PM
the wiki can be found here (link goes to the english page): http://projects.WebsiteBaker.org/websitebaker2/wiki/Docs-EN

To get this code going, create a page of type "code" and paste the code into this page. You will need to have a page of type "news", with some news-articles, otherwise this code has nothing to display.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: beeswax on January 02, 2007, 06:53:25 AM
Happy New Year.
I've pasted the code into a Code page, and it works, but what I'd like to do is to have the News "Headlines" in the sidebar, and when they click on "Read More" the detailed news opens in the Main page. I've looked at modify_settings.php (if that's where I should be looking) in the News module but I'm afraid that I can't make too much sense of it.
At the moment I'm working on the site "locally" so I can't give anyone a preview.
thanks, in advance
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on January 02, 2007, 09:31:57 AM
have a look at the templates "Gray Snake (http://w007be2b.dd15712.kasserver.com/pages/templates.php?template=gray-snake)" and "Metal Slabs (http://w007be2b.dd15712.kasserver.com/pages/templates.php?template=metal-slabs)" (the links are temporary links to the add-on pages! They will change!)


They have included, what you want to achieve.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: beeswax on January 03, 2007, 03:35:51 PM
I've downloaded MetalSlabs and installed it, and the News sections work how I want them to. I've gone into page settings and written down the settings as they appear in MetalSlabs so that I can change the template to Andreas02 and make sure the page settings are the same (the only difference being that instead of "Left Column", Andreas02 has "Sidebar"), and that's when it all falls apart for me. I really am at a loss as to what to do next :|
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on January 03, 2007, 04:55:13 PM
Have a look at the template sourcecode. There you can see, how it is implemented. You then take the script part and paste it into the template you want to use it ...

In the Andreas02 Template the code comes in like this here:

Code: [Select]
<div id="sidelink">
</div>
</p>
<-- Login Box start -->
<form name="login" action="http://w007be2b.dd15712.kasserver.com/account/login.php" method="post" class="login_table">
<h2>Login</h2>
Username:
<input type="text" name="username" style="text-transform: lowercase;" />

Password:
<input type="password" name="password" />
<input type="submit" name="submit" value="Login" style="margin-top: 3px; text-transform: uppercase;" />
<a href="http://w007be2b.dd15712.kasserver.com/account/forgot.php">Forgot Details?</a>
</form>
<-- Login Box End -->

<--News Box start -->

<?php
// Specify the Group(id) you want to read the news from or 0 for all groups
$group 0;       

// Specify number of newsitems                       
$limit=10;

// Specify read more text
$readmore "Read more";       

// Specify news text
$news "Latest News";       

// Query for obtaining stuff from a group
$query "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<) {
  
$query "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result $database->query($query);
$total $result->numRows();      // how many items are there?

if ($total>1) {                   // at least 2 needed for 2 news items
  
$data $result->fetchRow() ;   // get left item
  
$data2 $result->fetchRow() ;  // get right item
  
echo &#39;<span style="font-size: 14px; color: #fff; display: block; font-weight: bold; border-bottom: 1px solid;">&#39;.$news.&#39;</span>&#39;;
  
echo &#39;<p style="border-bottom: 1px solid #000; font-weight: bold; font-size: 12px; color: #fff;">&#39;.$data[&#39;title&#39;].&#39;</p><p style="font-size: 12px; text-align: justify; color: #fff;">&#39;.$data[&#39;content_short&#39;].&#39;<br /><a href="&#39;.WB_URL.PAGES_DIRECTORY.$data[&#39;link&#39;].PAGE_EXTENSION.&#39;">&#39;.$readmore.&#39;</a></p>&#39;;
  
echo &#39;<p style="border-bottom: 1px solid #000; font-weight: bold; font-size: 12px; color: #fff;">&#39;.$data2[&#39;title&#39;].&#39;</p><p style="font-size: 12px; text-align: justify; color: #fff;">&#39;.$data2[&#39;content_short&#39;].&#39;<br /><a href="&#39;.WB_URL.PAGES_DIRECTORY.$data2[&#39;link&#39;].PAGE_EXTENSION.&#39;">&#39;.$readmore.&#39;</a></p>&#39;;
}
else {
  echo &
#39;<span style="font-size: 14px; display: block; font-weight: bold; border-bottom: 1px solid;">No News yet ...</span>&#39;;
}
?>

<-- News Box ends -->
</div>

Then you just change the styles to what you need (all the styles used in this script are direct formatting).

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: mikejd on February 18, 2007, 03:03:40 PM
I have been trying to modify this code to use with the events module, inserted into a Code section.

The code I'm using is :

global $database;
$query = "SELECT date,event_desc FROM ".TABLE_PREFIX."2006mod_event_dates ORDER BY date DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

while($data = mysql_fetch_object($result)){
$title = $data->event_desc;

echo '<p><a href="">'.$title.'</a></p>';
}

and I get an error message :

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/fhlinux190/d/deveron-arts.com/user/htdocs/wb/modules/code/view.php(30) : eval()'d code on line 13

Is this code OK? or how can I change it to work?

Regards,
Mike Davies
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on February 18, 2007, 03:43:11 PM
I think you just forgot 2 closing semicolons behind the brackets: "};" but I might be wrong there since I am no real coder.

cheers

Klaus
Title: Anynews snippet module v0.10
Post by: doc on February 18, 2007, 03:46:13 PM
Hello,

Matthias (ruebenwurzel) asked me, if I could create a snippet module of the display news items anywhere code posted in that thread. Well here my first version.

Installation
 - download the attached zip file to your computer
 - log into the backend of WB and install the module as usual

Using the snippet function
Once the module is installed, it can be invoked either from the index.php file of your template or from any code module section.
Code: [Select]
<?php display_news_items(); ?>
For a more customised output, you can pass over serveral parameters to the function explained below.
Code: [Select]
<?php display_news_items($group_id$max_news_items$max_news_length
$header_text$readmore_text$no_news_text); ?>


Optional parameters (default values stated as well):
group_id... group from which you want to read news from (default:= 0 for all groups)
max_news_items... max. number of news shown (default:= 10, values>10 will be lowerd to 10)
max_news_length... max. length of the short news text shown (default:=150)
header_text...  heading text shown (default:="Latest news")
readmore_text...  text displayed for readmore link (default:=read more)
no_news_text...  text shown if no news available (default:="no news avaialbe yet...")

Have fun.
Regards Christian

Removed file. Any news is now available in the section Additional Functions on addons repository (http://addons.WebsiteBaker.org/pages/modules.php)
Title: Re: Code Snippet: Display news items, anywhere
Post by: YeShakka on February 19, 2007, 12:42:27 PM
Thank you for that. Nice contribution.

But shouldn't this go into "completed code snippets"?
Title: Re: Code Snippet: Display news items, anywhere
Post by: mikejd on February 19, 2007, 03:21:01 PM
kweitzel - I tried adding the ;s but it didn't work. i think they were in the right place. It stopped all the page after the code block from loading.

Thanks anyway.
Mike
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on February 19, 2007, 04:53:03 PM
@YeShakka
I am thinking to implement a feature which let you control how the news will be displayed.
Possible options:
 - display as list (only news header and read more link)
 - display as table (allow choice of columns to be used)

In addition I want some feedback first, before moving that snippet to the completed section.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: hr_d on February 19, 2007, 08:09:55 PM
Hello,

I install and tested the "display news items modul" without any problems. It will be nice to show also the short-text of the news.

Thanks to Christian for his good work.

Regards Hermann



Title: Anynews snippet module v0.11
Post by: doc on February 19, 2007, 09:35:49 PM
Hello,

please find attached the updated version of the anynews snippet module. To upgrade, just install it over the previous one.

Have added the additional parameter $display_mode which allows you to output a detailed list (news title, short text, link to news item), or a simple unsorted list (link to news item, link text = news title). In addition I added the option to display the full short text ($max_news_length=-1, which is now the default) or no short text at all ($max_news_length=0). The latest version creates now valid (X)HTML output (forgot the closing slash in the <hr /> element).

Code: [Select]
<?php display_news_items($group_id$max_news_items$max_news_length,
$display_mode$header_text$readmore_text$no_news_text); ?>


Optional parameters:
group_id...  group from which you want to read news from (default:= 0 for all groups)
max_news_items...  max number of news shown (default:= 10, no value >10 accepted)
max_news_length... max length of the short news text shown (default:=-1 for full news length)
display_mode... 1:=details (default); 2:=unsorted list
header_text...  heading text shown (default:="Latest news")
readmore_text... text displayed for readmore link (default:=read more)
no_news_text...   text shown if no news available (default:="no news avaialbe yet...")

[Edited 18.2.07, 22:38]
Example for customised call:
display_news_items(0, 5, 50, 2, "The latest news", "show full news text", "uup, no news available");

Troubleshooting:
 - pass over either no argument, or all arguments in expected order
 - mask text with "your text " or 'your text '
 - within your template index.php file use: <?php display_news_items(); ?>
 - within a code module use: display_news_items();
 - remind the ; at the end of the code line

Custom formating:
The output can be customized to your needs without touching the code itself. This is realised by the use of CSS definitions. Open a code page and enter the following code:
Code: [Select]
echo "<div id=\"mynews\">";
display_news_items(0, 3, 15, 1, "Last news", "more...", "no news yet");
echo "</div>";

The additional div section is used to restrict the style defintions to the news only, without influencing the rest of your layout. The following CSS examples needs to be added to the CSS file of your template.

The font size of the news text is too big?
Code: [Select]
#mynews p {font-size:80%; }
You want the news title to show up in brown?
Code: [Select]
#mynews strong {color:brown; }
The news header should have a left brown border?
Code: [Select]
#mynews h2 {border:1px dotted brown; margin:5px; padding:0;}
Please keep in mind: I will not aks any questions on CSS formating.
A lot of pages are available for free in the internet. http://www.css4you.de/, http://glish.com/css/

Regards Christian

Removed file. Any news is now available in the section Additional Functions on addons repository (http://addons.WebsiteBaker.org/pages/modules.php)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Hans on February 19, 2007, 09:58:26 PM
Hi Doc
thanks!
One problem though: when adding a space in $header_text or $readmore_txt I get this message:
Parse error: syntax error, unexpected T_STRING in /home/dernjen/public_html/modules/code/view.php(30) : eval()'d code on line 1

(I replaced $header_text and $readmore_txt with normal text (Dutch: Lees meer = English: Read more), maybe I have it the wrong way? When I replace it with one word or two with an underscore I get no errormessage (although the underscore is visible in the link).
Hans


Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on February 19, 2007, 10:03:24 PM
Hello Hans,

you need to pass over text in " " or ' ' like shown below:
display_news_items(0, 10, -1, 1, "Test test", "test tesset", " no test");
display_news_items(0, 10, -1, 1, 'Test test', 'test tesset', ' no test');

Have tested this and it works. If you forget the " ", the number of arguments will not fit the expected number.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Hans on February 19, 2007, 10:08:12 PM
Yes! That worked.
Thank you!
Hans
Title: Re: Code Snippet: Display news items, anywhere
Post by: hr_d on February 20, 2007, 09:34:51 PM
Hello,

works very well.

I have small pictures in the short text news!. It is possible to show these also?

Have a look: http://www.frettchen.raith.ws/pages/news.php (http://www.frettchen.raith.ws/pages/news.php)

Thank you!
Hermann
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on February 20, 2007, 09:42:35 PM
Hello Hermann,

not possible with the latest version, as I am using the PHP command strip_tags() to remove all HTML tags from the short text. So in your case, image tags like <img> will be striped from the short news text.

Try to remark the strip_tags command for short news text in line 83 in anynews/include.php
Code: [Select]
//$data['content_short'] = strip_tags($data['content_short']);
Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: hr_d on February 20, 2007, 11:04:20 PM
Hello Christian,

that worked fine. Thank you! http://www.frettchen.raith.ws/ (http://www.frettchen.raith.ws/)

Perhaps you can make a parameter in the next version.

Regards Hermann
Title: Anynews v0.12 available
Post by: doc on February 21, 2007, 05:00:53 PM
Have added the option to suppress striping off tags from news title, and short news text. In addition I removed all inline CSS styles, as they can´b be overwritten via external CSS definitions.

Added a README file to the zip file in the addons repository (http://addons.WebsiteBaker.org/pages/modules.php) which explains all possible functions.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: hr_d on February 22, 2007, 10:44:40 PM
Hello Christian,

I tested it, very good job!

Thank you. http://www.frettchen.raith.ws/ (http://www.frettchen.raith.ws/)

Regards Hermann
Title: Re: Code Snippet: Display news items, anywhere
Post by: G4 on March 09, 2007, 11:54:12 AM
Is it possible to show 2 newsitems on the frontpage from 2 different news pages. In the module i can not find a page ID. Or is there some other way to do this.

NEWSPAGE 1
item A
item B
item C

NEWSPAGE 2
item X
item Y
item Z


On the frontpage I want to show
LATEST
item A
and
item X
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on March 09, 2007, 12:17:32 PM
you can only (with the default setup) generate the different groups. Otherwise you will need to change the script, so it checkes the page_id as reference for the postings ...

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 11, 2007, 02:10:08 PM
@G4
You could try the following workaround:
Put all news items of Newspage 1 into a group (e.g. news1), all news items of Newspage 2 into another group (e.g. news2). Assuming that group news1 has the number 5, news2 the number 6, try the following code:

Code: [Select]
display_news_items(5, 1, -1, 1, "Latest News", "read more", "no news available yet...", true);
display_news_items(6, 1, -1, 1, "Latest News", "read more", "no news available yet...", true);

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Olli on March 15, 2007, 12:29:14 PM
hello everyone,
i tried the snipped a while back and i love it :-)

but there is one thing, that's not working properly. let's say you've got a WB-link inside the short-text area.

this WB-link does not get "translated" to the real URL.
it says "www.mydomain.com/pages/[wblink2]" or something like this.

is this fixed already?

thanks guys
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 28, 2007, 06:13:13 PM
@Olli:
I dont think that this is related to the anynews snippet, but to the news module itself.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: propelled on April 13, 2007, 11:19:23 AM
Hello.

Module anynews works perfect. I dont have experience with php and I need two things to get work this module correctly. Both thing with multilingual site.

First is: I want show texts Lastest News and Read More at language file, to make finnish or russian page fully finnish or russian. I tried replace it with [READ_MORE] but it dont work.

Second is: I have made multilingual site with tree what was explained on multilingual site wiki. It is right now this:
fin
- page1
- page2
- news (news on finnish language)
eng
- page1
- page2
- news (news on english)
rus
- page1
- page2
- news (news on russian)

How to make possible show with anynews module on russian page news on russian language and etc (same with other languges)?
Title: Re: Code Snippet: Display news items, anywhere
Post by: ruebenwurzel on April 13, 2007, 11:25:49 AM
Hello,

a few days ago a read a post where a user solved this with adding the language variable to the requests. Cannot find the thread, but maybe you have mor luck when you search yourself  :wink:

Matthias
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on April 13, 2007, 01:10:54 PM
Hello,

the code below assumes that you have sticked to the tutorial for multi language pages (http://projects.WebsiteBaker.org/websitebaker2/wiki/Docs-EN-Multilingual-Website). Languages specific pages must be stored in directories like:
DE: ../wb/de/home.php
EN: ../wb/en/home.php

Add the following code (without start <?php and ending ?> tags) into a page of the type code.

Code: [Select]
<?php
// getting the calling page URL (../webserver/en/home.php)
$current_page $_SERVER[&#39;PHP_SELF&#39;];

// using regular expression to extract the language part from the URL (/en/, /ge/, /it/...)
$language_used "";
if(
preg_match(&#39;#/(..)/#i&#39;, $current_page, $language)) {
  
$language_used $language[1];
}

// define text output depending on choosen language
switch ($language_used) {
  case 
"DE":  // german language
     
$news_header "Letzte Nachrichten";
     
$news_more "mehr...";
     
$news_no "keine Nachrichten vorhanden...";
     break;
  
  case 
"EN"// english language
    
$news_header "Latest News";
    
$news_more "read more";
    
$news_no "no news available yet...";
    break;
  
  default:  
// if LANGUAGE could not be detected
    
$news_header "Your heading text";
    
$news_more "Your more text";
    
$news_no "your no new text";
    break;
}   

// call the anynews snippet
display_news_items(010, -11$news_header$news_more$news_notrue);
?>


If someone knows a better way of extracting the page language, please post it here.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: 4bizmedia on June 12, 2007, 03:23:31 AM
Hi, just wondering if there was an easy way to eliminate the <hr> that is displayed at the end of each snippet, instead having just a blank space.  CSS can make the <hr> small, but can't eliminate it completely.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on June 12, 2007, 07:19:01 AM
Hello,

set the visibility of HR to none or set the color of HR to your background color or remove the HR from the code in include.php.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: kida on July 03, 2007, 01:24:03 AM
Hey - works well,

I need it for like an online daily diary..

Anyway to include the date the item was posted with anynews?

Cheers

Darren
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on July 03, 2007, 03:50:31 AM
Hello,

this is not supported, but you can implement that function by your own.

You need to modify the include.php of the anynews snippet. The output is generated between lines 92 and 121. The following code would extract the date from the database and convert it into human readable format (English style). Only place it within the while loop (lines 92-121).

Code: [Select]
echo date("m/d/Y", $data[posted_when]);
To style the output format of the date, have a look to the PHP function code (google)  :-)

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: kida on July 03, 2007, 04:53:53 AM
Hey

That's great - nice solution

Cheers

Darren
Title: Re: Code Snippet: Display news items, anywhere
Post by: sHsIkuA on July 26, 2007, 03:40:24 PM
Hello need some help here

The snippet only work when I put the group id to 0 , other than that its not working at all

Where can I get my group_id ?

Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on August 01, 2007, 06:54:30 AM
did you define groups in the newmodule? If yes, you can find the group ID by editing the group. Then it is shown in the URL of the page.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on September 07, 2007, 04:19:40 PM
Hello,

I hope I don't sound presumptuous, and I admit in advance that I haven't read this thread completely in detail. But I have taken kweitzel's code from the metal-slabs template and changed it a little to my needs.

You can find the changed code as well as a short description of what I did at my wiki: http://www.rot65.de/dokuwiki/doku.php/cms/WebsiteBaker/debug

Kind regards,
Ayshe
Title: Re: Code Snippet: Display news items, anywhere
Post by: DGEC on September 08, 2007, 03:21:48 AM
My german is worse than Google's  :-)

It looks interesting, but what exactly did you do?  Cleanup of the CSS and using styles instead of something else?
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on September 13, 2007, 02:58:03 PM
Hi,

the changes are quite minor but might be interesting for one or another in the forum, thus I posted them.
These are the changes in detail:
- The line "Latest News" above the teasers is not displayed anymore
- If no news are available the list is simply empty without showing the line "No News Yet"
- All inline css is discarted, css is left to everyone individually
- Teasers were displayed each as a paragraph; now they are displayed as list items in an unordered list
- The original script has the teaser title in one row and in the next row the link to the news; in my version the teaser title is the link to the news at the same time; this results in one line of linked text instead of two lines of text, one linked and the other not.

So, what you get with this version is a very minimalistic list of linked teasers. The styling is completely left to you and your own CSS.

Best regards,
Ayshe
Title: Re: Code Snippet: Display news items, anywhere
Post by: DGEC on September 13, 2007, 09:27:15 PM
Thanks Ayshe!  This is a good, I was thinking about doing several of the same things.

If you have a chance to answer, a couple more questions:

- looks like you've removed even the classes, correct? so it will validate now and we can either use the content block's default <ul> style or add a news specific <div> to the template and add <ul> to the css then

- do you know off-hand if the result of having no news is completely empty? i.e. If I capture the module output to a string, there is a null string if there is no news.  That's great if so, we can make appropriate alterations (either "nothing at the  moment" or change the layout. (someone smart posted code for that recently, I forget what it was related to). 
If not, don't worry, it will be tested anyway :)

I want to figure out how to get something the blog-style archive by date division going now...
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 18, 2007, 02:03:06 PM
If you use news on different pages without groups, you can display newsitems with anynews-snippet by using the "section_id" instead of "group_id".

To sort news by section_id, open the "include.php" in the anynews-snippet and replace all "group_id" with "section_id".
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on September 19, 2007, 08:51:34 AM
- looks like you've removed even the classes, correct? so it will validate now and we can either use the content block's default <ul> style or add a news specific <div> to the template and add <ul> to the css then

Yeah, that's the case. I removed the inside css to give maximum css flexibility and improve validation.
You can use whatever markup you like and style it with your own external css.

- do you know off-hand if the result of having no news is completely empty? i.e. If I capture the module output to a string, there is a null string if there is no news.  That's great if so, we can make appropriate alterations (either "nothing at the  moment" or change the layout. (someone smart posted code for that recently, I forget what it was related to). 
If not, don't worry, it will be tested anyway :)

I want to figure out how to get something the blog-style archive by date division going now...

I know what you mean, but right now can't answer your question since I can't access my code at the moment. But anyway, it should be easy to find out by yourself, just look into the code.

Regards,
Ayshe

Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on December 07, 2007, 01:14:15 PM
Hi,

Is it possible to add News to a WYSIWYG page?
I need news headlines + teasertext on my frontpage, not in the template file.

Thanks!
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 07, 2007, 02:08:51 PM
Sure,

a code snippet works in both, templates (index.php) and a page/section of type code. As WB allows to mix sections of different type (e.g. a WYSIWYG section, than a code section, than another WYSIWYG section on one page), you can achieve what you want (I guess).

If you want to learn more about sections, have a look on the WB help site.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on December 07, 2007, 09:26:03 PM
Thanks Christian!

It would work perfectly if only the WYSIWYG editor didn't add closing </div> tags to my code! Any way to prevent it from doing so?

Or I could add div tags in the code section, but how?

How would <div class="news"> be written in the code section?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 08, 2007, 06:30:08 AM
Hello,

the Help webiste provides a links to the PHP site which shows all the functions available in PHP.
So go to the Help website, switch to section Bookmarks and search for the PHP functions site.
Simply search for the PHP command echo which does what you want. The PHP site also provides examples of how to use the functions. Simply give it a try.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: ruebenwurzel on December 08, 2007, 07:11:20 AM
Hello,

@JonH
When you talk about code section what did you mean?
The source code window of the WYSIWYG Editor or a secttion with using the page typ code?

As this are two totally different places also the handling is different.

From your post i mean you use the source code of the WYSIWYG Editor, the explanations doc gave you are meant for a section with page typ code.

The call of the news snippet is thought for to place in index.php of template or in a section with page type code not in the source code window of the WYSIWYG Editor.

Matthias
Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on December 08, 2007, 10:13:51 AM
With code section i mean a code section under a wysiwyg page, not the code view <>.

My frontpage has sections:

WYSIWYG
CODE
WYSIWYG

And I need the news snippet to be placed inside a div, which starts in the upper WYSIWYG section and ends in the bottin WYSYWYG section. I'll have a look at the help docs.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 08, 2007, 10:47:04 AM
this should work (without starting and ending PHP tags)
Code: [Select]
<?php
echo &#39;<div class="news">&#39;;
display_news_items();
echo &
#39;</div>&#39;;
?>

Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on December 08, 2007, 12:18:12 PM
Thanks! it works like i planed :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 09, 2007, 11:39:17 PM
Hi ....

i have just uploaded and used the any news module... and it works fine :) ...

i just hava one minor question.... when i add a new post to one of my news pages (i use 3 different news pages).. .it does not always show up on top (actually it shows up at the bottom????  :? :? (in the show news anywhere page)! i want the latest (sorted after time) to be on top.. i have looked through the readme... but i cant seem to find it??
Title: anynews... acting weird!
Post by: babsy on December 10, 2007, 12:19:09 PM
i know i have asked for this in another forum.. but that was a loooong forum, so maybe you didn´t see it!

i am using the anynews module... and it is working fine.... exept one thing!!!!
i just can´t figure out why the newest news don´t show up at the top???? :?

i have 7 news pages.. and they all show up in the anynews page, but they show up.. random... ??

anyone know why!:

here is the page: http://www.vagaportal.com/

the anynews are in the first top page "forsíða",

[Edit]Merged to the orgiginal thread. Please do not start several threads for one and the same thing. Module and Code snippets should be discussed in the module/code snippte thread. It makes it not easier to keep track of the problems nor you will get faster answers. (doc)
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on December 10, 2007, 07:02:32 PM
I bet your problem is the MySQL Statement ... it says "order by Position" while you want to have it ordered by the timestamp ...

You'll need to rewrite the file include.php lines 70 and 72 so that the SQL statement includes:
Code: [Select]
ORDER BY posted_when
not tested though!

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 10, 2007, 09:38:55 PM
thank you, thank you.... .thank you.. you just saved my day....  :-D :-D :-D

that was it...... sorry, i dont´know this coding part to well, yet... but im learning.. .thanks.. again :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 11, 2007, 08:46:22 AM
just another question that i could´nt find the answer to in this thread!

if i have 4 groups in my news (group id_1 and Group id_2 and Group id_3 and group id_4)
and i just want to show group 1, 2 and 4 in my anynews!??

is that possible?? and how to i set up the groups... it looks like this right now:

echo "<div id=\"mynews\">";
display_news_items(0, 10, 50, 1, "Seinastu tíðindi", "Les meira", "Ongin nýggj tiðindi í løtuni", false);
echo "</div>";

i have tried:
echo "<div id=\"mynews\">";
display_news_items(3-4, 10, 50, 1, "Seinastu tíðindi", "Les meira", "Ongin nýggj tiðindi í løtuni", false);
echo "</div>";

but it still shows all groups!! is this even possible :)?
Title: Re: Code Snippet: Display news items, anywhere
Post by: DGEC on December 11, 2007, 05:32:38 PM
Well, according to the initial posting of the snippet, the parameters are:

Quote
Optional parameters (default values stated as well):
group_id... group from which you want to read news from (default:= 0 for all groups)
max_news_items... max. number of news shown (default:= 10, values>10 will be lowerd to 10)
max_news_length... max. length of the short news text shown (default:=150)
header_text...  heading text shown (default:="Latest news")
readmore_text...  text displayed for readmore link (default:=read more)
no_news_text...  text shown if no news available (default:="no news avaialbe yet...")

The easy way then would be if you just do:
Code: [Select]
echo "<div id=\"mynews\">";
display_news_items(1, 10, 50, 0);
display_news_items(2, 10, 50, 0);
display_news_items(4, 10, 50, 0);
echo "</div>";

Note that each group will be separately listed and they won't all be mixed together by date. 

If you dig into the PHP & SQL code, you can find where the variable is read and you could hard-code multiple values if you really want everything co-mingled.
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 11, 2007, 06:25:13 PM
Hi again, and thanks for the answer, but i really need them do be ordered by date, so thats not a possibility... well. maybe i could have someone dig in to the php mysql for me :) im unfortunatly not to great with codes.. ... but i´ll write it here if i come up with a solution!
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 12, 2007, 08:54:25 AM
well, so far no news. im looking for at programmer to try this for me! about the groups!! so it can show all groups exept 1.. and then the 1 will show up in another side of the page...

but i have one question that you maybe know, if the picture in the short text is to high, the articles "overlap" eachother, does any one know why??? or where i can fix this. i have been looking through the code and changed some minor things like the read more is gone now.. and the title is the link.. and that worked fine....but i can´t figure out this image in the short text??
 :? it looks like this:

www.vagaportal.com
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on December 13, 2007, 09:30:51 AM
well.. i just asked my clients to use "enter" until the line is under the image.... hmm.. so it works... i have one more question.. about this...  that the value 10....

i have tried to make the value 15... is that not possible.. it stills shows 10 news.. not 15 ?? why and can i change that.. ? :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 13, 2007, 10:10:44 AM
Hello,

maybe you should take the time to read the documentation which is provided with the snippet.
Addons: http://addons.WebsiteBaker.org/pages/modules/code-snippets.php
Module thread: http://forum.WebsiteBaker.org/index.php/topic,409.msg34735.html#msg34735

To solve your problem you have to change the PHP code.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: pszilard on December 26, 2007, 08:01:22 PM
Dear Argos,

Where can I find instructions for using GHTML menus with WB? I have bought a license for it years ago, and would love to make use of it in WB!

Thnx,
Title: Re: Code Snippet: Display news items, anywhere
Post by: pszilard on December 26, 2007, 08:08:35 PM
When I try to use the News snipet and save, I get the following:

Quote
Not Implemented
The page you are looking for cannot be displayed because a header value in the request does not match certain configuration settings on the Web server.

This message also raises it ugly head at other times. Any clues what is going on here???

ps: this is an error 501
Title: Re: Code Snippet: Display news items, anywhere
Post by: marathoner on December 26, 2007, 10:40:01 PM
You didn't provide very much information. Are you using the snippet in a template or in a code section?

A 501 is "Not Implemented"...could it be that you are trying to use a service not supported by your host? You say that you get a 501 at other times...what other times?
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on January 02, 2008, 07:52:33 PM
hi again  :-) it works fine here, but i have one question!

i have just installed it on an old webpage i had, but when i install it, it just says, "update successful" but it doesn´t show up when i look through my modules?? then i went in to my ftp to just delete it... but it wont allow me to delete, and i can´t un-install it, because it doesn´t show up on my add-ons list  :? any ideas?
Title: Re: Code Snippet: Display news items, anywhere
Post by: ruebenwurzel on January 02, 2008, 09:33:00 PM
Hello,

Quote
on an old webpage

Wich WB version is running there. Code snippets are only supported from 2.6.5 and higher.

Cause the permissions please look on our help page. There is all explained.

Matthias
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on February 11, 2008, 01:48:32 PM
Hi ...

it works fine.. i have updatet wb...

Its a great module... :-D

but its still bugging me that the "line" under the text is overlapping if i have a picture in the small text.... the line "jumbs around"..... and it doesn´t look nice.... and the only solution i can figure out it so "enter" until it looks nice, but thats not a very smart solution... so  :?

i have tried to change it, but no luck, so if anyone has a solution, please post it here!! :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: dbrorlando on February 12, 2008, 07:24:18 PM
I've used news anywhere several times, but I need to use it for a specific layout which includes the "published date", "news title" and "display name".  Can someone please help me?... I've spent most of the past few days trying to make it work.  I did find the post showing how to add the date, and was able to change it to show the published date, but when I add multiple news items, the dates don't display correctly.

Here's an example of what I'm looking for:

 02.12.2008 - Name of Article - Author's Display Name
 02.11.2008 - News Title Here - Author's Display Name
Title: Re: Code Snippet: Display news items, anywhere
Post by: diodak on March 15, 2008, 09:03:07 AM
I've used news anywhere several times, but I need to use it for a specific layout which includes the "published date", "news title" and "display name".  Can someone please help me?... I've spent most of the past few days trying to make it work.  I did find the post showing how to add the date, and was able to change it to show the published date, but when I add multiple news items, the dates don't display correctly.

Here's an example of what I'm looking for:

 02.12.2008 - Name of Article - Author's Display Name
 02.11.2008 - News Title Here - Author's Display Name

I dont know what method you are using, try mine:

Code: [Select]
if ($data['posted_when'] != "") {
$output .= "<div class=\"any-date\">".date("M d, Y",$data['posted_when'])."</div>\n";

near line 108 in include.php
Title: Re: Code Snippet: Display news items, anywhere
Post by: falkena on March 16, 2008, 10:26:17 PM
Hallo,
I have installed the new wb 2.7.
with the new news module i can put an start date an end dat to the news.
the problem is that anynews wil show it anyway.
Is there a way to fix this?
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on March 16, 2008, 11:04:52 PM
The anynews snipet was not written for this functionality (checking the on and off times). it will need to be rewritten for that purpose.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: marathoner on March 18, 2008, 02:06:07 AM
The snippet allows you to customize the output any way you want on any page you want. It's simply a tool to extract fields from the news table. In order to be 'aware' of the start/end date you will need to customize the output to do this (just like someone may want to ignore the start/end date). Simply modify the query to only extract those records that fit your criteria and then display whichever fields you want in whatever way you want.
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on April 07, 2008, 01:34:22 PM
but its still bugging me that the "line" under the text is overlapping if i have a picture in the small text.... the line "jumbs around"..... and it doesn´t look nice.... and the only solution i can figure out it so "enter" until it looks nice, but thats not a very smart solution... so  :?

i have tried to change it, but no luck, so if anyone has a solution, please post it here!! :?

Hi,
this is not a problem with the code snippet. You should specify stylesheet definitions for the appearance.

Regards,
spida.
Title: Re: Code Snippet: Display news items, anywhere
Post by: vanbemmel on April 10, 2008, 08:54:13 AM
Hello,

when i paste this code in my template i don't see any news.
What can i do wrong?


I made very rough code, that makes a listing of a specific group(id)
With the option of setting a "max results", and order them by date added. etc..

Just read the code, play with it. Refine it, restyle it.

Have fun..

Code: [Select]
<!-- NEWS READER -->
<?php
$group 
0// Specify the Group(id) you want to read the news from

global $database;

$query "SELECT post_id,title,group_id,link 
          FROM "
.TABLE_PREFIX."mod_news_posts
          WHERE group_id = 
$group
          ORDER BY posted_when DESC 
          LIMIT 0, 5;"
// This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
          // The first number defines the starting point, and the second the max/end of the results
$error mysql_error();
if (!
$result mysql_query($query)) {
    print 
"$error";
    exit;
    }

while(
$data mysql_fetch_object($result)){
  
$title $data->title;
  
$id $data->post_id;
  
$link $data->link?>

        <p>
         <a href="<?php echo WB_URL?><?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>
         </p>
         <?php
    
}
?>

<!-- END NEWS READER -->
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on April 10, 2008, 09:22:52 AM
Hello,

habe you tried the original code snippet module AnyNews from the Addons repostiory?

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on May 06, 2008, 11:52:30 AM
Hi,

How can I remove the 'read more' function if there is no long text placed?

I checked the doc and the forum but could not find a solution.

Grtz
Knert
Title: Re: Code Snippet: Display news items, anywhere
Post by: ruebenwurzel on May 06, 2008, 12:42:47 PM
Hello,

where did you wanna remove it?

In the news modul itself? look at the options of the news modul
or in the any news snippet? look at include.php in modules/anynews directory

Matthias
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on May 06, 2008, 02:21:56 PM
Hi Matthias,

I use the anynews snippet for use on the homepage. I already checked the include.php but could not find where to change it.  :x

It's not that I completely want to remove the read more on the homepage, only when there's no long text written.

But I noticed just a few seconds away that you cannot click the text to go to the news function on the newspage itself. Only if there's a read more link.

So I adviced the client to use the short as the long text as well. Problem solved. Thnq for taking the time to respond.

Grtz
Knert  :-)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Nowis on May 22, 2008, 12:43:47 PM
Hallo,
I have installed the new wb 2.7.
with the new news module i can put an start date an end dat to the news.
the problem is that anynews wil show it anyway.
Is there a way to fix this?


I can be done quite easily. You just have to edit modules/anynews/include.php

Code: [Select]
// query to obtain news items for the selected group
if ($group_id < 1) {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE active=1 ORDER BY position DESC LIMIT 0, $max_news_items;";
} else {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE group_id=$group_id AND active=1 ORDER BY position DESC LIMIT 0, $max_news_items;";
}

must be changed to

Code: [Select]
// query to obtain news items for the selected group
$t = time();
if ($group_id < 1) {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE active=1 AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) ORDER BY position DESC LIMIT 0, $max_news_items;";
} else {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE group_id=$group_id AND active=1 AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) ORDER BY position DESC LIMIT 0, $max_news_items;";
}
Title: Re: Code Snippet: Display news items, anywhere
Post by: shlack on May 24, 2008, 02:49:24 PM
Hi,


How can I remove the 'read more' function if there is no long text placed?

I checked the doc and the forum but could not find a solution.

Grtz
Knert

According to a Readme file you should use the following function:

display_news_items($group_id, $max_news_items, $max_news_length, $display_mode,
$header_text, $readmore_text, $no_news_text, $strip_tags);

Example for customized call:

<?php display_news_items(0, 5, 50, 2, "The latest news", "show full news text", "uups, no news available", false); ?>

So just use empty string instead of "show full news text":

<?php display_news_items(0, 5, 50, 2, "The latest news", "", "uups, no news available", false); ?>

Title: Re: Code Snippet: Display news items, anywhere
Post by: Olli on May 28, 2008, 03:49:05 PM
hello everybody,

i just read through the whole thread again but i don't know where to look for for a solution.

just to get a basic understanding what is needed: is the anynews module able to display <img>-tags properly that were inserted inside a news entry? right now all img tags and paths are destroyed when using anynews and i don't know why...

it does not matter if i turn stripping tags on or off... the img path is always broken/not there...

the path looks something like
Code: [Select]
http://local...%3c/p%3E%3Cp%3E%3Ca%20href=
can someone lend a helping hand? :-)

greetings
Title: Re: Code Snippet: Display news items, anywhere
Post by: marathoner on May 29, 2008, 03:06:41 AM
The module is intended to be customized to meet your needs. By default, the 'content_short' field is displayed after it is stripped of tags (including IMG tags) but this can be changed so that they are not stripped. It sounds like you've done that. The script should then output whatever is stored in your database. Have you checked your database to see what is stored for your news postings?

It may be an encoding issue such as the database and your web page being encoded differently.

I did a test myself by creating a posting with an image in it and the module displays it fine once I comment out the strip_tags.

Here is the regular news posting and the same posting using Anynews module.
http://www.mohican100.org/pages/registeredpage/test-news.php (http://www.mohican100.org/pages/registeredpage/test-news.php)
http://www.mohican100.org/pages/registeredpage/test-anynews-module.php (http://www.mohican100.org/pages/registeredpage/test-anynews-module.php)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Olli on May 30, 2008, 12:02:04 AM
hello marathoner,

thanks for digging into this!
could you please tell me where exactly you commented out the stripping tags? i guess this is the point where i went wrong...

bye
Title: Re: Code Snippet: Display news items, anywhere
Post by: marathoner on May 30, 2008, 01:33:09 AM
@Olli-

I have to apologize. I had commented out line 92 in the example that I listed above and that you looked at. It worked just fine; however, it wasn't until just now when I went back to see what the line number was did I realize that the display_news_items function already has this functionality built into it as the last (8th) parameter. You can simply call the display_news_items function as is with the 8th parameter set to FALSE (it's set to TRUE by default).

I've modified my example links above so that you can see the function called with default parameters and with the STRIP_TAGS parameter set to FALSE.

If this doesn't fix your problem, take a look at the data stored in your mod_news_posts table and see if the posting has your IMG tags in it.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Olli on May 30, 2008, 06:25:45 PM
@marathoner: when displaying the news the regualar way (looking at the news page directly) everything is fine. all tags are there and nothing is broken.

but when using the anynews script all images are destroyed no matter if it set the strip-tag flag to true or false. i'm a bit stuck now i must admit. i can't get any progess into this.

using the old snipped from pc wacht does not help either. this is really confusing because it used to work in the past on another installation...

maybe this is a PHP5 concerned problem? hmm...

thanks for your help marathoner, will look at it all over again and will do a reinstall just to see if that helps...

greetings
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 30, 2008, 06:55:48 PM
Hello,

just and idea, disable the output filter (if used) and check again.

Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on June 02, 2008, 09:46:35 AM
Hi, has anyone a solution for the bottom line, it "jumbs around", my client has to press enter until its below the text... Is there a way to make it automatic going to the bottom :)  :? without using enter :) :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Olli on June 02, 2008, 10:15:16 PM
Hi, has anyone a solution for the bottom line, it "jumbs around", my client has to press enter until its below the text... Is there a way to make it automatic going to the bottom :)  :? without using enter :) :?

i'm not quite sure what you mean. please tell a bit more about your problem. i'm sure there is a solution - does not sound that spectacular ;-)

regards
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on June 03, 2008, 10:01:59 AM
hi... if you look at www.vagaportal.com in IE, and then look at it in Firefox, you will see what i mean... it´s the bottom line, that is between the news..  :-)
Title: Re: Code Snippet: Display news items, anywhere
Post by: marathoner on June 03, 2008, 03:47:02 PM
Display differences between browsers is, um, a browser issue and not an issue with the Anynews module. Simply play with your CSS to achieve the desired results. I would guess that this is related to float (or in your case image align since you didn't use float). I also noticed a bunch of empty DIV's in the news item that doesn't display the HR correctly.
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on June 03, 2008, 04:19:08 PM
hi... ok, thanks.. for your help... i´m going to try to make it look good :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 07, 2008, 05:18:37 PM
For all WB2.7 users of any_news..

I modified the snippet so it now respects start and end dates of the posts.
The modification was done because someone had a problem with posts being showed where they should not be showed anymore. https://forum.WebsiteBaker.org/index.php/topic,10233.msg60019.html#msg60019 (https://forum.WebsiteBaker.org/index.php/topic,10233.msg60019.html#msg60019)

The solution tests for the WB version, and is compatible with the WB 2.6.7 version.

Cheers,

Ruud

EDIT: Attachment removed. Newer version available through addons repository.

Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on July 07, 2008, 05:22:14 PM
Thanks, a bugfix was already postet in reply #142 (https://forum.WebsiteBaker.org/index.php/topic,409.msg57589.html#msg57589) of this thread. Will add a working solution to the addons repository if my time allows to do it.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 07, 2008, 05:30:09 PM
That's fine Christian.

The fix you referred cannot be used in 2.6.7 sites, so you cannot use this in a download version.
My version will do the same (ofcourse), but only when > 2.7 is used. 2.6.x will use the old query.

Just have a look at it when you have got time.

Cheers,

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on July 07, 2008, 08:21:02 PM
Hello Ruud,

I know about the short comings of the version I posted.

Unfortunatelly there is a bug in the news module (http://projects.WebsiteBaker.org/websitebaker2/changeset/853) of WB 2.7, which needs an additional workaround to get anynews working with 2.6.x, 2.7 RC1 to final and any future 2.7.x.

Therefore no update of the anynews snippet is available so far on the addons repository. Best thing would be to check for database fields instead of version numbers to make sure anynews works on all platforms. Will have a closer look on this issue once time does free up in the future.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 25, 2008, 09:52:46 PM
Despite the existing bug and workaround that might be needed, I made a small modification in the last version.

In this post (https://forum.WebsiteBaker.org/index.php/topic,10508.0.html) the problem was reported there is no translation for internal links in the snippet.

In this version (v0.14) this is fixed.

Ruud

EDIT: Attachment removed. Newer version available through addons repository.
Title: Re: Code Snippet: Display news items, anywhere
Post by: DarkMaster3960 on July 29, 2008, 10:05:08 AM
Heya,

ok, its early morning and it was a very sleepless night, so please excuse my question, but i dont know where or how to add news with this very nice snipped.

So far ive added a custom code to one of my pages but theres always shown: there are no news available yet.

And are there any options in the backend where i could change anything?

Thanks for your help...
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 29, 2008, 10:14:09 AM
First create a news page (you can hide from the menu if you want).
In there you can create the news items. AnyNews will see the created items automatically.

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: DarkMaster3960 on July 29, 2008, 10:19:02 AM
thanks, but

if i use a code page, how can i create news items there? i thought it uses the database for news?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 29, 2008, 10:24:20 AM
You don't need to create the news-page in the same place.

You need a page (anywhere) to input (and display the full article).
The AnyNews snippet could be used in a code-section (if you need it on a single page) or in your template/index.php (if you need it on every page).

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: DarkMaster3960 on July 29, 2008, 10:29:48 AM
ok, i think ive understod but could you give me an example please?

Thanks a lot, i think any news is exactly what i looked for...  :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on July 29, 2008, 10:39:16 AM
Please have a look here:
WebsiteBaker Help Project - News (http://help.WebsiteBaker.org/pages/de/basis-doku/umgang-mit-wb/seitenverwaltung/seiten-aendern/news.php)

That will help creating a news page.

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: DarkMaster3960 on July 29, 2008, 10:46:35 AM
Ohhhh I LOVE YOU!!!

Its so weird, it was right in front of me and i didnt see this... ahh awfull...
everything i need is already integrated in WebsiteBaker and is didnt see this...

Cruel world...

ARGH, im so sorry that is wasted your time with this kiddieshit...
but, just as i said, its early in the morning and the first walk i made was to the computer and straight into this forum. as i got up this morning i thought i had THE idea...

Ok, remember, first FAQ then google, then the forumsearch and then POST...

Thank you... -.-'
Title: Re: Code Snippet: Display news items, anywhere, css problem, where?
Post by: babsy on August 01, 2008, 10:24:39 PM
hi, i know i have asked about this before, but i have tried to change the css anyway i know, but i still can´t get the line between the news to show right (i still have to make "enter" until it´s below the image i use, and then the "read more" text goes to far down, looks a bit weird!...

is there anyone who can help me in the right direction with this... or tell me where to change it! i have tried to change the css file... but no luck there, ???? :mrgreen:
Title: Re: Code Snippet: Display news items, anywhere, css problem, where?
Post by: Ruud on August 01, 2008, 10:39:47 PM
is there anyone who can help me in the right direction with this... or tell me where to change it!

Can we have a look somewhere?

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on August 01, 2008, 10:49:44 PM
www.hfhmagazine.com

my problem is the anynews " on the left", when i use pictures in the short text!!, you see the second, third nr. news and so on, i have used "enter" to regulate is, but it does not look good, i want the ...read more, to come right after the text and even if i use a big picture i want the line (hr) to come at the bottom, not to the right (even if i choose "left" in the picture edit)!!

hobe you know what i mean, i know this is css question, but i just can´t figure it out??!!
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on August 01, 2008, 11:01:43 PM
Try adding
Code: [Select]
#mynews p {
overflow:auto;
}

Is that what you want?

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on August 01, 2008, 11:08:17 PM
yesssssssssssssss thank you thank you thank you, thats just what i have been looking for :)

ubs, exept i wanted the "read more" to be at the end of the text,... but this is still much better  :) then before!
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on August 01, 2008, 11:20:46 PM
A bit risky.. but looks good

Code: [Select]
#mynews h2 {
  text-align: right;
  margin-top: -20px;
}

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on August 03, 2008, 01:59:12 PM
now its perfect, thanks for your help :)

i read in the thread that someone had found out how to show the date (posted when) with the anynews! but i can´t find the code for that in the forum, can anyone point me to the post for that?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on August 03, 2008, 04:16:49 PM
In the AnyNews "include.php" find the line:

Code: [Select]
// OUTPUT NEWS ITEMS WITH NEWS TITLE, SHORT NEWS TEXT AND READ MORE LINK
Below that line the output is created.
Depending on the location where you need the date/time to appear you could add:

Code: [Select]
$output .= "<p class=\"dateformat\">".gmdate("d M Y, H:i", $data['posted_when']+TIMEZONE)."</p>\n";(class "dateformat" is added so you can use CSS to position and size things.)

Cheers,

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: lepracaun on September 15, 2008, 11:44:05 AM
Hi, I have been trying to add the cde snippet to my page under my menu on the left, as soon as I paste the code into my index.php file and want to preview it, the page is blank. I have set up the news module in admin, and created a few sample news articles, any idea why it will be doing this?
This is the code I have tried to paste into index.php

Code: [Select]
<!-- NEWS READER -->
<?php
$group 
0// Specify the Group&#38;#40;id&#38;#41; you want to read the news from

global $database;

$query "SELECT post_id,title,group_id,link 
          FROM "
.TABLE_PREFIX."mod_news_posts
          WHERE group_id = 
$group
          ORDER BY posted_when DESC 
          LIMIT 0, 5;"
// This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
          // The first number defines the starting point, and the second the max/end of the results
$error mysql_error&#38;#40;&#38;#41;;
if &#38;#40;!$result = mysql_query&#38;#40;$query&#38;#41;&#38;#41; &#38;#123;
    
print "$error";
    exit;
    &
#38;#125;

while&#38;#40;$data = mysql_fetch_object&#38;#40;$result&#38;#41;&#38;#41;&#38;#123;
  
$title $data->title;
  
$id $data->post_id;
  
$link $data->link?>

        <p>
        <a href="<?php echo WB_URL?><?php echo $link ?><?php echo PAGE_EXTENSION?>"><?php echo $title?></a>
        </p>
        <?php
    
&#38;#125;
?>

<!-- END NEWS READER -->
Title: Re: Code Snippet: Display news items, anywhere
Post by: Argos on September 15, 2008, 11:52:53 AM
Somehow your code is polluted by stuff like #38;#41;
They prevent the script from working. Please download the latest version on the bottom of page 8 and try again.
Title: Re: Code Snippet: Display news items, anywhere
Post by: lepracaun on September 15, 2008, 12:02:45 PM
Thanks Argos
That was the problem  :-)
Title: Re: Code Snippet: Display news items, anywhere
Post by: ghost06 on September 28, 2008, 01:30:13 PM
hi boys,
how I can make in order to visualize the list of the existing groups?

sorry for my english :lol:
Title: Re: Code Snippet: Display news items, anywhere
Post by: Argos on September 28, 2008, 01:34:48 PM
how I can make in order to visualize the list of the existing groups?
This is not possible with this snippet, because it shows latest news per group, or all groups together. To show the groups themselves, just use the normal news page.
Title: Code snippet anynews v0.21 released
Post by: doc on October 20, 2008, 12:16:43 PM
Hi,

just released version 0.21 (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php) of the anynews snippet on the addons repository. The module is based up on v0.14 published by Ruud E and hence includes the fixes for the publish by date function and for internal WB links.

Version v0.21 introduces two new options.

Apart from that, some code cleaning, language support and a HTML help file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html) was added to v0.21.

Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?

Regards Christian
Title: Re: Code snippet anynews v0.21 released
Post by: Ruud on October 20, 2008, 02:39:38 PM
Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?

Done,

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on October 21, 2008, 02:12:34 PM
Trying to make a templete were "Any News", depending of language set on the page, list news from one of two sources. Is it hard to do this? 
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 21, 2008, 02:28:55 PM
I've done this by using 2 news groups. Dutch / English
I didn't set the language in the pages, but used a /pages/en/ or /pages/nl/ page structure.

Code: [Select]
<?php
$url 
$_SERVER[&#39;REQUEST_URI&#39;];
if (function_exists(&#39;display_news_items&#39;))  {
  
if (strrpos($url,"/en/"))  {
    
display_news_items(1,3,-1,1,"Latest news","read more","No news available",false); 
  } else {
    
display_news_items(2,3,-1,1,"Laatste nieuws","verder lezen","geen nieuws beschikbaar",false); 
  }

?>


Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on October 21, 2008, 02:31:31 PM
Thnx Ruud will try it out..
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 21, 2008, 02:33:30 PM
I missed one line you will need to have too:

Before testing the $url variable, it needs to be defined with something ;-)
Code: [Select]
$url = $_SERVER['REQUEST_URI'];
Ruud


Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 22, 2008, 01:26:22 PM
hi... again :)
i was wondering where if you know where i can change the month name :)

i use this extra line in the include.php
$output .= "<p class=\"dateformat\">".gmdate("d M Y", $data['posted_when']+TIMEZONE)."</p>\n";

but the date comes out in english, ex. 23 oct. ... and i want to change it to 23. okt.
i have looked in the language files, but can´t find it there - is it possible to change it :)

otherwise everything is working perfect now :)...... www.sudurras1.com
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 22, 2008, 01:42:02 PM
You can use the function strftime() instead of gmdate().

Code: [Select]
$output .= "<p class=\"dateformat\">" . strftime("%d %B %Y",$data['published_when'])."</p>\n";
(example is using WB2.7 published_when instead of WB2.6 posted_when)

By default, it uses the locale settings of your php configuration.
For more info on how to tweak strftime and local languages, see: http://www.php.net/strftime

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 22, 2008, 01:54:47 PM
thanks :)  :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on October 23, 2008, 03:53:04 PM
there is one small problem with the wb 2.7 and anynews :)

the clock possibility in the news, does not work with anynews - meaning even if i choose that the a certain news, should not be shown until 8 pm .... it comes out in the anynews right away?
but it works fine on the news page, and dosn´t show up until 8 pm....

So if anyone has a solution, i would love to hear about it  :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on October 23, 2008, 08:41:06 PM
The snippet needs to be adjusted for that function to work. Currently it does not consider the times and/or dates.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 23, 2008, 10:52:37 PM
Klaus is wrong here,

The current version of Anynews will respect the published date and time. Using exactly the same rules as the news service itself.

Check the version you are running. Version 2.1 (http://addons.WebsiteBaker.org/modules/dlg_by_groups/dlc.php?file=218) is the current one.


Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on October 24, 2008, 05:20:29 AM
Should have done some better research then :-D didn't actually check. Sorry about that ...

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on October 28, 2008, 05:59:45 PM
I missed one line you will need to have too:

Before testing the $url variable, it needs to be defined with something ;-)
Code: [Select]
$url = $_SERVER['REQUEST_URI'];
Ruud


Works like charm!

If you want to have the first 3 news with heading and short text display_news_items(0,3,40,1) and the next 10 wit just heading like display_news_items(3,10,0,1), is it possible?

Anyway thanx alot for the code..
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 28, 2008, 10:02:57 PM
If you want to have the first 3 news with heading and short text display_news_items(0,3,40,1) and the next 10 wit just heading like display_news_items(3,10,0,1), is it possible?

No, not without changing the any_news snippet code.
The snippet will always show the last n messages, it will not skip the first n.

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on October 30, 2008, 09:00:28 AM
Code: [Select]
<?php
$url 
$_SERVER[&#39;REQUEST_URI&#39;];
if (function_exists(&#39;display_news_items&#39;))  {
  
if (strrpos($url,"/en/"))  {
    
display_news_items(1,3,-1,1,"Latest news","read more","No news available",false); 
  } else {
    
display_news_items(2,3,-1,1,"Laatste nieuws","verder lezen","geen nieuws beschikbaar",false); 
  }

?>

I noticed a small problem as the URL changes when you read a newspost the /en/ part dissapears. Then the script then shows the default news parts. Is trere any variable not shown in the URL that one can locate to know what newsgroup that you read from? When will I be able to do some PHP magic like you Ruud =)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on October 30, 2008, 09:51:18 AM
You could decide to not show the anynews at all on the page where you are reading.

Replace the } else { with } else if (strrpos($url,"/nl/")) {.
(also a searchpage would not show a wrong language newsblock that way)

For the rest I cant tell what is in your URL unless I can see it ;-)

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on November 04, 2008, 11:44:19 AM
Nice! Got it to work..but when i view the page with all news "they" are back ofcource so doday I was thinking if the ?lang=SE part in the URL can be useful. So pages with ?lang=SE see this news and pages with ?lang=GB se that news? Possible?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on November 04, 2008, 11:58:27 AM
I would just create a news page for every language. You can define per language-newspage where links will be linking to.

The lang=SE parameter is only available as a parameter when switching languages. There is a static variable LANGUAGE available within your template. That will hold the same value as the lang= parameter when switching languages.

Ruud



Title: Re: Code Snippet: Display news items, anywhere
Post by: Lotus on November 04, 2008, 12:06:57 PM
I realize that this is vital information but I can not do anything with it, frustrating. Will RTFM =)
Thank you for pointing me in the right direction though but for now I stick with your code..it is the best thing I got.
Title: Re: Code Snippet: Display news items, anywhere
Post by: testdriver2 on November 18, 2008, 12:56:46 PM
I would like to thank the website baker community for providing excellent modules. I have used the latest version of the module provided on this site and I have integrated it into my website www.auyana.de.
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on November 20, 2008, 05:57:33 PM
Wow, cool design! There's a forum called showcase here in the community forum. Maybe you want to introduce your website there.

Cheers,
spida
Title: Re: Code Snippet: Display news items, anywhere
Post by: spida on November 20, 2008, 06:44:02 PM
Hi there,

I don't get the display working.
If I use this code according to the readme
Code: [Select]
if (function_exists('display_news_items')) {
    display_news_items(9, 5, 50, 1,
'Best Practice Beispiele', 'Weiterlesen', 'Momentan in Bearbeitung...',
false, '<a><img>', true, ' (d.m.Y)');
}

I only get text, some tags, no link for the full text, no images, and everything in very big letters (see image 01).

If I change strip tags from false to true, it's still the same, just in smaller letters (see image 02)

In either case images are not displayed, but there alternative text instead.

It would be really nice if someone checks my code and tells me what I am doing wrong here. I am a bit clueless right now, can't see the error in it.

Thanks in advance,
spida

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 10, 2008, 07:27:08 AM
Hello,

anynews v0.21 showed an warning (E_ALL) if the anynews function was called more than once on one page. This is fixed in the latest version 0.22 available on the add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php). Just download the latest version and install it over the existing one via the WB backend.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on December 10, 2008, 10:28:49 PM
Hello

I did not get the publish date displayed at my anynews code-section:
Code: [Select]
display_news_items(2, 5, 150, 1,
  'Latest News','Details', 'uups, no news available',
  true, '<a><img>', true,'(h:i, d.m.Y)');

Any suggestions?

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 10, 2008, 10:42:23 PM
Hello.
Do you mean here?:
http://www.websitebakers.com/

Strange.
It should work.

Did you notice any another problems with the standard modules?

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on December 10, 2008, 10:47:32 PM
Quote
Do you mean here?:
http://www.websitebakers.com/
Yes.
And no: there are no problems (known) on the site.
But there is another site with the same result.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 10, 2008, 10:51:36 PM
If the another site is hosted by the same provider...  :wink:
else ... I don't know.

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on December 10, 2008, 11:10:15 PM
No,
another hoster.

rgds

erpe
Title: Anynews v0.30 beta
Post by: doc on December 10, 2008, 11:13:28 PM
Hello guys,

please find attached a beta version of the next anynews release.

Installation / De-installation:
As this version uses the same parameter list as the previous versions, there is no need to modify existing calls. Simply install v0.30 (beta) over an existing version via the WB backend and you are done. If you experience any problems, de-install the beta version via the WB backend and install the stable version v0.22 from the add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php).

Whats new:
Version v0.30 (beta) uses two HTML template files located in: "modules/anynews/htt" to style the output for the list format and the detailed output. This allows to add or remove any tags you want without touching the PHP code itself. This way, one can realize table or div based outputs of the news items without touching a single line of PHP code.

The following placeholders can be used in the "*.htt" files:
Quote
NEWS INFO: {TITLE}, {POSTED_WHEN}, {CONTENT_SHORT}, {LINK}
FUNCTION ARGUMENTS: {ARG_HEADER_TEXT}, {ARG_READMORE_TEXT}, {ARG_NO_NEWS_TEXT}
Note: the "no news text" is added automatically if no news exist.

The placeholder {TITLE} contains the title of the news article from the news database, whereas {ARG_HEADER_TEXT} contains the text passed to the function as 5th parameter ($header_text).

Think this modification in combination with CSS should allow alos users not that familar with PHP to modify the output according their needs.

As usual, feedback, comments or proposals welcome.

Regard Christian

[Edit]File removed. Lastest version available from addons repository[/Edit]
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 10, 2008, 11:38:13 PM
Cool stuff, Doc.

Will test tomorrow.

@Erpe... in this case - I don't know.

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on December 11, 2008, 12:47:35 AM
Hi Doc,

sorry for the question, but how can I use this?

rgds


erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 11, 2008, 07:11:46 AM
@Erpe:
Install anynews v0.30 locally and check out the files contained in /htt. The files are pure text files containing HTML tags and placeholders like {TITLE}. This files control the order and overall apearance of the news output. There is a help file contained in the module.

There were a lot of discussions in this thread regarding moving outputs from a to b, to get rid of paragraph tags etc. creating div or table layouts. The previous solutions required to touch the PHP code and a lot of end users are not that familar with doing this. Therefore I decided to introduce the HTML template files to make it more practicable. The files may be editable by the use of the "edit module files" module.

For abaut 80% of the users nothing will change, the other 20% have the freedom to style the output like they want.

Christian
Title: Code Snippet: Display news items, anywhere
Post by: doc on December 13, 2008, 12:16:02 PM
Hello,

just released Anynews v0.31 (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php) on the Add-ons Repository.

Installation / De-installation:
Simply download the latest version and install it via the WebsiteBaker backend. No need to de-install existing version

Whats new:

The template files (pure HTML) allows you style the output without touching the PHP code of the module itself. Details can be found in the module help file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Regard Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Katerchen on December 28, 2008, 09:54:09 AM
Great enhancement! I just wanted to start modifying v0.21 because I need some changes to the default layout of the news entries in v0.21, but v0.31 makes this obsolete as I can modify the template files now. Exactly what I nedded. Thank you!

There are just two modifications I still have to make:

1. Why is max_news_items limited to a maximum of 10? Currently there is no way to change this hard-coded limit without modifying the PHP code (which is trivial though). Parameter checking is always a good idea, but why this very low maximum value? Why not set it to a higher value (e.g. 1000, the default could be left to 10 to maintain as much backward compatibility as possible)?

2. I would like to have an additional placeholder that uses the database field published_when instead of posted_when (for displaying and/or sorting). The field published_when is visible and settable in the backend via "Start date" while posted_when is not. Again, it doesn't seem to be very difficult to implement, so I'm going to try this soon.

At least #2 could be implemented as an enhancement to v0.31 which is 100% backward compatible - is there any interest in it?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on December 30, 2008, 02:02:29 PM
Hello,

both can be implemented with the next release. The field published_when was first introduced with WB 2.7. Setting 10 as max. was in my opinion a good choice, but can easily be changed.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Katerchen on December 30, 2008, 03:08:22 PM
This is good news! One more suggestion: The template files are hardcoded as well. This prevents the author of a website from using different templates in different news pages, which could be very handy, because the news module can also be used for other kinds of pages than just displaying news which sometimes requires different formatting.

Why not make the template filename (or its subdirectory name "htt") selectable via a parameter? This would enhance the flexibility of the snipped by far and is probably easy to implement.

Happy New Year!
Title: Re: Code Snippet: Display news items, anywhere
Post by: chabar2000 on January 04, 2009, 10:04:56 AM
Does anybody have the same problem: max_news_length does not work, short text is always shown completely.
Code: [Select]
<?php
if (function_exists(&#39;display_news_items&#39;)) { display_news_items(0, 2, 10, 1,   &#39;News&#39;, &#39;Read more...&#39;, &#39;No news&#39;); } ?>
Any hint? Thank you!
Karl
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 04, 2009, 08:22:06 PM
Hello,

just released Anynews v0.32 (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php) on the Add-ons Repository.

Installation / De-installation:
Download the latest version from the WebsiteBaker Add-ons repository. Uninstall previous versions of Anynews via the WebsiteBaker backend if available, then install the latest version.

Whats new:

Details can be found in the module help file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Regard Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: albatros on January 05, 2009, 03:46:46 PM
Hi Christian,

it's my favorite module, so I want to thank you for your work!

Best regards

Uwe
Title: Re: Code Snippet: Display news items, anywhere
Post by: Katerchen on January 06, 2009, 01:10:27 PM
Excellent! It's getting more and more flexible and works well here. Thank you!

Would it make sense to add a third "sort_by" parameter (e.g. 3) which sorts by the field PUBLISHED_WHEN? In this case the field PUBLISHED_WHEN could be taken as a creation date which is visible/modifyable via the backend and automatically sorted by this date.

Is it really necessary to deinstall the old version first before installing a newer version?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on January 06, 2009, 01:22:45 PM
Would it make sense to add a third "sort_by" parameter (e.g. 3) which sorts by the field PUBLISHED_WHEN? In this case the field PUBLISHED_WHEN could be taken as a creation date which is visible/modifyable via the backend and automatically sorted by this date.

I would also appraciate seeing this happen.

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 06, 2009, 03:40:26 PM
Hello,

just released Anynews v0.33 (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php) on the Add-ons Repository.

Installation / De-installation:
Download the latest version from the WebsiteBaker Add-ons repository. Uninstall previous versions of Anynews via the WebsiteBaker backend if available, then install the latest version.

Whats new:

Details can be found in the module help file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Regard Christian

@Katerchen: Yes it is required to delete an existing version, as I have changed filenames which will not be deleted via the normal update procedure. However, as Anynews is a code snippet, you do not need to delete any page or code section before uninstalling the module as it is the case for page modules like Zitate, Guestbook ...
Title: Re: Code Snippet: Display news items, anywhere
Post by: Katerchen on January 06, 2009, 04:23:07 PM
Just installed v0.33 - sorting by published_when works great! But now sort_by = 1 seems to be broken - it sorts by published_when also. Take a look at line 114 in include.php - does this construction really work?

Edit: I just replaced
Code: [Select]
$sql_sort_by = ($sort_by == 1) ? 'position' : ($sort_by == 3 && $add_sql != '') ? 'published_when' : 'posted_when';
with a nested "if" clause and it worked again, so this line seems to be the culprit.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 06, 2009, 05:22:00 PM
Hi,

well missed a bracket pair. The line below should work as expected.

Code: [Select]
$sql_sort_by = ($sort_by == 1) ? 'position' : (($sort_by == 3 && $add_sql != '') ? 'published_when' : 'posted_when');
Have replaced the version on the Addon repository (still labeled version v0.33, so delete an existing version and replace it with the new one).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Katerchen on January 06, 2009, 05:42:10 PM
Okay, now it works. Thank you! BTW: The snippet has vanished from the "official" code snippet page...
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 06, 2009, 06:16:59 PM
Quote
BTW: The snippet has vanished from the "official" code snippet page...
Thanks, forgot to activate the snippet - fixed.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Maarten8 on January 13, 2009, 10:14:44 AM
Is it possible to add it to a page?
Like if I go pages > add page?
If no, is it possible to just show it on only one page?

(really nice module btw)

Maarten
Title: Re: Code Snippet: Display news items, anywhere
Post by: Argos on January 13, 2009, 10:22:18 AM
Is it possible to add it to a page?
Like if I go pages > add page?
If no, is it possible to just show it on only one page?
Sure, make a code section and put the snippet in there. I recommend using the code2 module: http://www.websitebakers.com/pages/admin/core-replacements/code-2.php. It's more versatile than the default code module.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Maarten8 on January 13, 2009, 11:10:53 AM
Is it possible to add it to a page?
Like if I go pages > add page?
If no, is it possible to just show it on only one page?
Sure, make a code section and put the snippet in there. I recommend using the code2 module: http://www.websitebakers.com/pages/admin/core-replacements/code-2.php. It's more versatile than the default code module.

Woah thanks for the fast response :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on January 13, 2009, 05:59:39 PM
is there a way to link the title header to the news it's showing (when it's only 1 group)?

like in there http://www.votreespace.net/pages/nouvelles.php
the "derniere realistion" is another news in a subsection, other than making the link manualy in the call, can we activate a link to the group?

because something like this :
Code: [Select]
if (function_exists('display_news_items')) {
    display_news_items(0,10,50, 2,'<a href="/pages/nouvelles/derniere-realisations.php">Dernières mise-a-jour</a>', 'Voir...', 'oups, aucunes mise a jour');
}
do not seam to work.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 13, 2009, 06:14:35 PM
Hello,

should be doable with the latest version of anynews released recently on the addon repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php).

You can style the output of anynews by modifying the HTML templates included in the folder /htt of anynews as described in the README file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: saiborg on January 14, 2009, 09:42:00 PM
Sorry, but im toooooo silly,

i can´t implement the code....i already changed some code in the anynews/include.php
but i can´t make the $max_news_length shorter

Code: [Select]
if (function_exists('display_news_items')) {
    display_news_items($max_news_length);
}


an what do i habe to change that there ist not the full short text, only thirty to fourty letters....

Code: [Select]
$group_id = 0, $max_news_items = 10, $max_news_length = -0, $display_mode = 1,         $header_text = 'Aktuel', $readmore_text = 'weiter lesen', $no_news_text = 'no news available yet...',         $strip_tags = true, $allowed_tags = '<a>',        $display_publish_date = false, $date_time_format = ' (g:i A, m/d/Y)',        $sort_by = 1, $sort_order = 1)
Thank you for your help

Saiborg
(sorry for my english)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 22, 2009, 05:29:42 PM
Hello,

just released Anynews v0.34 on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php).

This version fixes a bug which made it impossible to make use of the custom output template files like: custom_output_display_mode_X.htt (X for a number between 3 and 99). Thanks to Erpe for reporting.

Further details can be found in the Readme file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Delete any previous version and install the latest version afterwards.

Have fun
Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Maarten8 on January 26, 2009, 02:31:46 PM
Is it possible to put the anynews in a WYSIWYG page?
So if you make a new page and use as type WYSIWYG.
Because I would like it at the frontpage only (so no use to put it in template) and I kinda need to have a WYSIWYG page for some other users.

thanks.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 26, 2009, 03:12:00 PM
Hello,

yes, simply add a WYSIWYG section and a code section to a page. Then call the Anynews function from the code section. This way you do not need to touch your template. Details about section can be found on the WB help site:
http://help.WebsiteBaker.org/pages/en/basic-docu/working-with-wb/page-administration/manage-sections.php

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Maarten8 on January 27, 2009, 11:12:15 AM
Hello,

yes, simply add a WYSIWYG section and a code section to a page. Then call the Anynews function from the code section. This way you do not need to touch your template. Details about section can be found on the WB help site:
http://help.WebsiteBaker.org/pages/en/basic-docu/working-with-wb/page-administration/manage-sections.php

Regards Christian

Thanks it totally works  :mrgreen:
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on February 04, 2009, 12:33:43 PM
hi.... i just updated, and my picture dissapeared, so now its. just text??
is it not possible in the latest update to have the picture in the small text??
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on February 04, 2009, 05:06:26 PM
Hello,

need to check if the striptags options are missing for the short text in the last version of Anynews.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on February 04, 2009, 05:53:33 PM
ok, i tried to look through the old code, but i really don´t see what code is for the picture, so if anyone knows, please let me know!
Title: Anynews: Display news items, anywhere
Post by: doc on February 05, 2009, 08:40:30 PM
Hello,

the bug should be fixed in the latest version available on the WB Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ymmot on February 18, 2009, 11:36:27 PM
Hi all.
Thanks a lot for a great forum and dedicated community. :)
I am a fairly new user off website baker, I like it a lot!
I tweaked some files here and there and got most working like I want it.

Now to the topic:
What I would like with anynews is the ability to show news starting from news item X!

On the front page I would like to show one news item with text and 5 more with just links.

But with the code here under the first full will be the same as the first in the second group.

Any way to work around or any way it´s possible to add to the anynews code?

Code: [Select]
if (function_exists('display_news_items'))
{
display_news_items(0, 1, 230, 1, 'Latest News', 'show full news text', 'uups, no news available', true, '<a><img>', true, ' (Y-m-d)', 2, 1);

display_news_items(0, 5, 0, 2, 'More News', 'show full news text', 'uups, no news available', true, '<a><img>', true, ' (Y-m-d)', 2, 1);
}

Thanks for any tips and help!
Title: Re: Code Snippet: Display news items, anywhere
Post by: Argos on February 19, 2009, 10:58:31 AM
hi,

try it with two sections .....

first section take the "latest news" - modul from here....
http://www.websitebakers.com/pages/modules/listings/section-pages/latest-news.php (http://www.websitebakers.com/pages/modules/listings/section-pages/latest-news.php)

it shows the last news-post full...

second section take the anynews for the links to the rest of the news.... :wink:

I think the question was how to let the anynews module start with the second latest item, instead of the latest one...
Title: Re: Code Snippet: Display news items, anywhere
Post by: daydreamer on March 03, 2009, 12:32:04 PM
Sorry this is all new to me, I need to show

5 posts
News Title
Short Description max 40 length
read more

What code would I need in my index.php

Many Thanks
Title: Re: Code Snippet: Display news items, anywhere
Post by: mr-fan on March 03, 2009, 12:37:41 PM
http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html)

try and learn about this snippet and you can get the output of the newsmodule that you want... :wink:

regard martin
Title: Re: Code Snippet: Display news items, anywhere
Post by: daydreamer on March 03, 2009, 12:55:01 PM
This is what I have but no short description is showing?

<?php display_news_items(0, 5, 50, 2, 'Latest News', 'read more', 'no news yet', '<a>', 'do not show publish date', '1', '1'); ?>
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on March 03, 2009, 12:59:32 PM
The 4th parameter should be set to 1.
2 means you will get a list of links only.

Quote
display_mode...    1:=details (default); 2:=unsorted list; 3-99 (custom template: /htt/custom_output_display_mode_X.htt)

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: daydreamer on March 03, 2009, 01:13:10 PM
Thanks so much guys all sorted
Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 03, 2009, 05:24:30 PM
How does this snippet deal with the possibility that there are more than one news pages? Can I specify which page I want to display the news items from?

Thanks,

Konrad
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on March 03, 2009, 05:33:50 PM
If you have multiple News pages you will need to use the group id.
Create a group for every newspage to use, and use the first parameter to show only that group.

It works fine for multilanguage sites. (used it like that before)
Groups like "Dutch news, English News, etc.."

Ruud

Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 03, 2009, 05:51:11 PM
Great stuff, thanks.

If I have multiple news pages and assign group = 0 in the snippet, what is the order of the news items based on? It seems to display them randomly but I would like to display the top news item from each individual news page.

Is there any way of doing this?

Thanks,

Konrad
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 03, 2009, 05:53:04 PM
Hi Konrad,

have a look at the Readme file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html) coming along with Anynews. Guess the last two options sort_order and sort_by are your friend.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 03, 2009, 06:16:48 PM
Thanks Christian,

I've upgarded to the latest version and followed the instructions in the read me - I understand it orders it based on the date / time, either ascending or descending?

Presuming I have 5 news pages, is there any way to display the top post of each news page rather than just the 5 latest posts?

Thanks!

Konrad
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 03, 2009, 06:29:30 PM
Hi,

anynews only allows to list x news from either all news pages (group id = 0) or from a certain group (group id > 0). However, you can think off calling the function 5 times (one call per group) and limiting anynews to show only one news per group. This in combination with a user defined template (/htt/custom_output_display_mode_X.htt) should do the trick even if it is not that straight forward.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 03, 2009, 06:44:49 PM
Thanks Christian,

I was thinking along similar lines but unfortunately I don't think it will work in this scenario - Ill try something else.

Thanks very much for your help though! :wink:
Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 04, 2009, 11:32:45 AM
I noticed it is possible to allow certain tags using 'allowed_tags' but is it also possible to only allow these tags (img and a) and exclude any text? This way I could show the image and use that as a link and could make it look a bit more 'designed'.

Thanks,

Konrad
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 04, 2009, 11:42:20 AM
Hi Konrad,

this is not possible in any of the Anynews version available. Anynews simply uses the PHP strip_tags function with the option to define tags which should not get removed from the text. However, feel free to change the code to fit your needs.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: sparkdigital on March 04, 2009, 11:47:10 AM
Okay, never mind!

K
Title: Re: Code Snippet: Display news items, anywhere
Post by: daydreamer on March 12, 2009, 11:17:33 AM
Read more links to /index.php on each post not to the actual post?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 14, 2009, 08:40:28 AM
Hi,

Anynews v0.40 is available on the WebsiteBaker Addons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).

Main changes:
 - anynews function was renamed from display_news_items() into displayNewsItems()
 - the old function name still exists, but was marked deprecated, which means it will be removed in future versions
 - some code clean up

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on March 15, 2009, 06:59:01 PM
Ok, what am I missing?

I have 2 news groups, Group-X and Group-Y and want to display news from Group-X on my front page by using:

Code: [Select]
<?php displayNewsItems(05502
  &
#39;Latest news&#39;, &#39;read more&#39;, &#39;No news available&#39;,
  
true, &#39;<a><img>&#39;, true, &#39; (d.m.Y)&#39;, 1, 1); ?>

What do I put instead of 0 as the first parameter? I tried 1 and I tried Group-X, none worked. It only shows news from all groups...
Is group id same as group title?

Help pls!

(I'm using latest version of wb and anynews)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 15, 2009, 07:18:42 PM
Hello,

the group is is numeric. Go the the WB backend and vist the page of type News (not Anynews). Look for the section called: "Modify / Delete Groups" which lists all the groups you have created. Go with the mouse over the group name and look in the browser status bar (in Firefox at the bottom). Here you see a link with the numeric group_id. If you don´t get it, simply click on the link of the group you are interested. The group_id can be found in the URL.

If it still not works, make sure you have assigned the news entries to one of those groups. Per default, news entries are assigned to the group_id 0, you need to add news entries manually to a group to get it working.

The parameter to touch is the first one. If still in doubt, have a look at the README file (http://addons.WebsiteBaker.org/modules/anynews/help/help_en.html).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: JonH on March 15, 2009, 07:32:51 PM
Aaahaaaa! That mouse over trick did the job.
Thank's a lot!
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on March 17, 2009, 02:04:23 PM
to make the "Title" the link also?
anyone who knows?, there was now trouble in the old code, but i just can´t figure it out in this new code?
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on March 17, 2009, 02:24:32 PM
Hi

you have to modify the standard template in anynews and add
Quote
<a href="{LINK}">{TITLE}</a>
in that row.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on March 17, 2009, 02:39:50 PM
Do you mean in this code part (i tried, and the pages keep turning blank)? (this is in the module/anynews/index.php ?

// replace the news article dependend template placeholders
                $tpl->set_var(array(
                    'TITLE'                => ($strip_tags) ? strip_tags($row['title']) : $row['title'] ,
                    'CONTENT_SHORT'        => $row['content_short'],
                    'POSTED_WHEN'        => ($display_publish_date) ? date($date_time_format, $row['posted_when']) : '',
                    'PUBLISHED_WHEN'    => isset($row['published_when']) ? date($date_time_format, $row['published_when'])
                                            : date($date_time_format, $row['posted_when']),
                    'LINK'                => WB_URL . PAGES_DIRECTORY . $row['link'] . PAGE_EXTENSION
                ));
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on March 17, 2009, 02:42:30 PM
What version of anynews do you use?
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on March 17, 2009, 02:50:37 PM
i think i found.... under modules/anynews/htt/detailed_output.htt

looks. like thats its... i just have to customize it now!

anynews is on the right... here:

http://www.is.fo/


i use the latest version.. i think :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on March 17, 2009, 03:02:13 PM
Yes, that's the template........

Add the link and you are done.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: babsy on March 17, 2009, 03:16:11 PM
thanks for you help :):)
 
Title: Re: Code Snippet: Display news items, anywhere
Post by: Gitrian on March 26, 2009, 09:48:29 AM
Hi,

I wondered if it was possible, in addition to the max number of news-items shown, also to specify how old the news-items must be, to be shown on the list ?

For example I want max 5 items and no one older than 1 month.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 26, 2009, 10:26:05 AM
Hi,

this feature would require to modify the code in the file include.php and to add another control parameter to the function. As the function already has 13 parameter, users may get lost with the options.

Another option is to deactivate "older" news via the WB backend manually.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Gitrian on March 27, 2009, 01:05:59 PM
Hi,

If I deactivate "older" news via the WB backend, I can't see them anymore in the news page (correct me if I'm wrong), so I think I'll have a look at include.php and try to modify the file myself.

Thanks for responding.

Regards Brian
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 27, 2009, 07:51:40 PM
Hello,

Quote from: Gitrian
If I deactivate "older" news via the WB backend, I can't see them anymore in the news page
Thats true. Released a new version of Anynews at the Addons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218) which introduces the variable $not_older_than. This allows you to show only news posted within the last x days. For the last 12 hours simply specify 0.5. Details can be found in the Readme file.

Regards Christian
Title: Display news items in table layout
Post by: doc on April 02, 2009, 05:41:09 PM
Hello,

please post any questions related to anynews in this thread instead of sending a PM at the first place. This may give the hint to other users which may have similar issues. Thanks.

Quote from: question raised via PM
... I would realy love to integrate the anynews snippet in a table (for lay-out puposes) in the homepage for website for my school. As you can see on the homepage of http://www.jonatan.be, the cell under "schoolnieuws"  should be filled with the news, but is not. Further on the page I've used the code-module and then put the snippet in it. That does work, but is not quite as pleasent looking. ...

My public answer:
Think this can be achieved by using a custom template file as described in the Anynews README (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) file. Have a look at /modules/anynews/htt/custom_output_display_mode_3.htt.

Try to play around with the template file. Try something like:
Code: [Select]
<table>
<!-- BEGIN news_block -->
<tr>
<td><strong>{TITLE} {POSTED_WHEN}</strong></td>
<td>{CONTENT_SHORT}<br />
<a href="{LINK}">{ARG_READMORE_TEXT</a>
</td>
</tr>
<!-- END news_block -->
</table>

Remember to set the display mode to 3 as described in the README file. Try the admin tools Addon File editor (http://addons.WebsiteBaker.org/pages/modules/admin-tools.php#id_248) from the WebsiteBaker repository if you have no glue how to modify the Anynews template files.

Good luck
Christian
Title: Code Snippet: Anynews
Post by: doc on April 14, 2009, 10:05:42 PM
Hello,

just released v0.71 of the Anynews code snippet on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).

The Readme file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) was updated accordingly and explains the parameters to use.

Modifications with respect to previous version:
 ~ moved language specific text outputs (e.g. read more, date/time format settings) to language files
 - removed parameters: $header_text, $readmore_text, $no_news_text, $date_time_format
 + removed support for outdated function call display_news_items()
 + use displayNewsItems() instead
 + added option to output news in random order ($sort_by = 4 as requested in the German forum)

Installation / Update:
Delete a previous version via the WB backend. Then install the latest version from the backend.

Remember to adapt your function parameters in code sections and/or the index.php file of your template!!!

Old parameter list:
Code: [Select]
<?php 
<?php displayNewsItems($group_id$max_news_items$max_news_length$display_mode
  
$header_text$readmore_text$no_news_text
  
$strip_tags$allowed_tags$show_publish_date$date_time_format,
  
$sort_by$sort_order$not_older_than); ?>

?>

New parameter list:
Code: [Select]
<?php 
displayNewsItems
($group_id$max_news_items$max_news_length$display_mode$lang_id,
  
$strip_tags$allowed_tags$show_publish_date,
  
$sort_by$sort_order$not_older_than); 
?>


If you use custom template files, check and replace the following placeholders:
Code: [Select]
{ARG_HEADER_TEXT} --> {TXT_HEADER}
{ARG_READMORE_TEXT} --> {TXT_READMORE}
{ARG_NO_NEWS_TEXT} --> {TXT_NO_NEWS}

Requirements:
 + Requires WebsiteBaker 2.7 or higher
 + the old function call display_news_items is no longer supported use displayNewsItems instead
 + check the parameter function

As usual, your feddback, suggestions etc. are welcome.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on April 15, 2009, 09:18:26 PM
Hello,

just released v0.80 of the Anynews code snippet on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).

The Readme file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) was updated accordingly and explains the parameters to use.

Modifications with respect to previous version (v0.70 / v0.71):
 + $group_id supports multiple groups (default:= 0 all groups, X:= group X, for multiple groups: array(2,4,5) )
 + $lang_id = 'AUTO' first checks language in URL (e.g /EN/ --> domain.com/pages/en/page.php) than in LANGUAGE constant

Installation / Update:
Delete a previous version via the WB backend. Then install the latest version from the backend.

Note:
If you have want to upgrade from a version older than v0.70, you need to update your functions calls and templates as explained in this post (https://forum.WebsiteBaker.org/index.php/topic,409.msg82855.html#msg82855).

Regards Christian
Title: Code Snippet: Anynews
Post by: doc on April 17, 2009, 09:09:33 PM
Hello,

just released v0.92 of the Anynews code snippet on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).
The Readme file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) is up to date.

Main changes:
 - removed legacy support for outdated WebsiteBaker versions 2.6.x and below (requires WB 2.7 or higher to work)
 - reworked the parameter sanity checks and moved routine into functions file
 - removed surrounding <p> tags from {CONTENT_SHORT} placeholder (added '<p>' to allowed tag list)
 - code clean up
 - replaced old function calls in file comment blocks with the new call (v0.91)
 - removed obsolete variables and debug information (v0.92)

The support of Anynews for WebsiteBaker versions 2.6.x or lower has expired with Anynews v0.90. Since Anynes v0.90 you need WebsiteBaker 2.7 or higher as minimum requirement for Anynews.

Installation / Update:
Delete any previous version via the WB backend. Then install the latest version.

Note:
If you want to upgrade from an Anynews version older than v0.70, you need to update your functions calls and templates as explained in this post (https://forum.WebsiteBaker.org/index.php/topic,409.msg82855.html#msg82855).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: abidan on April 25, 2009, 11:00:22 PM
Hi

I am having trouble getting the array function to work with this module. This is what I am putting into my index file to show in my menu:
 <?php
             displayNewsItems(array(1,3,4,6,7,8,9), 5, 50, 2,
                  '<h2 class="rightmenu"><a href="/pages/articles-tutorials.php">Latest Articles</a></h2>', 'read more', 'no articles available', false, '<a>', false, '', 1, 1);
              ?>
This should show the related groups news items in the array i have specified, but whenefver i use the array functions instead of eitehr 0 for all or X for a particular group it returns "no articles avaliable" even thoug htere are news groups with the numbers in the array?

I simply cant get the array part to work? has anyone got any ideas?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on April 26, 2009, 06:08:32 PM
Hi,

please update your function call to the latest version available. The stuff like 'read more' etc. is no longer supported.
The function parameters are described in the Anynews README file. If not already done, please update to version 0.92 of Anynews.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: abidan on April 26, 2009, 06:10:02 PM
Hmmmmmmmmm i think it must have been me doing something wrong (probably due to 2 glasses of wine lol) because when i tried it all again this morning it all worked!!!! strange

Thanks for advice anyway :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: eazybaker on May 06, 2009, 08:40:06 PM
I've done this by using 2 news groups. Dutch / English
I didn't set the language in the pages, but used a /pages/en/ or /pages/nl/ page structure.

Code: [Select]
<?php
$url 
$_SERVER[&#39;REQUEST_URI&#39;];
if (function_exists(&#39;display_news_items&#39;))  {
  
if (strrpos($url,"/en/"))  {
    
display_news_items(1,3,-1,1,"Latest news","read more","No news available",false); 
  } else {
    
display_news_items(2,3,-1,1,"Laatste nieuws","verder lezen","geen nieuws beschikbaar",false); 
  }

?>


Ruud

Hi,i tried that code,but its not working for me,because i use estonian and english language on my site,so
my question is,how i must modify that code to make it work?
thank you :-)

My  Page structure looks like this:
(http://img65.imageshack.us/img65/7775/screenshotgjv.th.png) (http://img65.imageshack.us/my.php?image=screenshotgjv.png)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 06, 2009, 08:56:36 PM
Hello,

please check out the latest Anynews version (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218), which includes a feature to automatically detect the language from the URL or from the page or section language defined via WB. Details about this feature can be found in Section C of the Anynews README (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) file.

To make this feature working for languages other than German or English, you need to create a Anynews language file for your language and copy it to the Anynews language folder. Currently supported languages are: German (DE.php) and English (EN.php).

If you have created a new Anynews language file, please add it as XX.txt file to this thread and I will add it with a next release of Anynews.

By the way, Anynews language files in other languages like Dutch etc. are also appreciated  :wink:

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: eazybaker on May 07, 2009, 12:03:15 PM

If you have created a new Anynews language file, please add it as XX.txt file to this thread and I will add it with a next release of Anynews.

Regards Christian

Hi,tnx i got it working.

Also is it possible to modify it like: when i click on english,it display only news i added to this language,when i click on estonian,then it display only estonian news???
now i have all news i posted on two languages,but can i modify it somehow to display only news from that language what i choose???

Added Estonian language file for anynews as attachment

thank you

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: D72 on May 07, 2009, 01:47:36 PM
Hello, i've got two questions.
On a website i use 'Event Calendar' and the module it self doesnt have the possibility to show the latest
events listed in a block.
Is there any way to grab the latest 4 events with AnyNews?
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 07, 2009, 06:51:36 PM
Hi,

@eazybaker:
Thanks for the language file. By the way. Does a Estonia language file exists for the WebsiteBaker backend? Guess it should be EE.php but I haven´t found one yet.

Quote from: eazybaker
... but can i modify it somehow to display only news from that language what i choose???
You can add all English news to its own group and all Estonian news to another group. Than you can set the first parameter of Anynews to show one of the groups depending on your page / section.

@D72:
Quote from: D72
Is it possible to get the title truncated to a certain amount?
Sure, but you need to adapt the Anynews code to achieve that. Check for line 187 in the file include.php. This line needs to be adapted e.g. with substr to truncate the title after XX characters.

Quote from: D72
Is it possible to show the latest events from Event Calendar
Well the tool is called anynews not anyeventcalendar, so the answer is no. However, you could copy Anynews rename it to anycalendar and adapt the database queries to fetch content from the calendar table.

Quote from: D72
Is there any way to grab the latest 4 events with AnyNews?
Yes and the HowTo is explained in the README file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) of the module.

Regards Christian
Title: Anynews v0.93
Post by: doc on May 07, 2009, 07:22:00 PM
Hello,

just released Anynews v0.93 (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218) which includes the Estonian language file contributed by the forum member eazybaker.
At eazybaker - thanks for your contribution, highly appreciated.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: D72 on May 07, 2009, 07:43:30 PM
Quote from: doc
Hi,
...
Regards Christian

Hello Christian,
Thanks for answering.
In order to truncated the titles of anyNews, i shall check this out. I'm not sure about my mysql and database skills, but maybe the the include.php page explains enough for me. I'm certainly give it a try.
About getting headlines by anyNews of the EventCalender...
I will ask this question in the topic of Event Calendar. Maybe someone in there got a brilliant idea.

Also, are you still in the need of a Dutch translation?
I thought it allready has a Dutch file in it.
Wich files should be translated? Only translate EN.php to a NL.php ?
Otherwise, count me in to translate it for you.
It's a good exercise for me to get AnyNews better... Nice module, but for a beginner... a pain in the ass...
Title: Re: Code Snippet: Display news items, anywhere
Post by: eazybaker on May 07, 2009, 08:33:16 PM
Quote
You can add all English news to its own group and all Estonian news to another group. Than you can set the first parameter of Anynews to show one of the groups depending on your page / section.
Regards Christian

thank you,i didnt know about this,because i make my first website with WebsiteBaker


Hi,

@eazybaker:
Thanks for the language file. By the way. Does a Estonia language file exists for the WebsiteBaker backend? Guess it should be EE.php but I haven´t found one yet.

Yes Estonia language file exists for the WebsiteBaker backend and its EE not EST,so i made mistake,sry abot that

Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 08, 2009, 12:05:34 AM
Hi,

@eazybaker:
Quote from: eazybaker
Yes Estonia language file exists for the WebsiteBaker backend and its EE not EST,so i made mistake,sry abot that
Strange, I found no EE.php in the WB /language folder. But anyway, thanks for your contribution  :wink:

@D72:
Quote from: D72
In order to truncated the titles of anyNews, i shall check this out. I'm not sure about my mysql and database skills, but maybe the the include.php page explains enough for me. I'm certainly give it a try.
Check out php.net (http://php.net/manual/en/function.strpos.php) to give it a try. If you fail with your attempts, simply show what you tried and ask for help in this thread.

Quote from: D72
Also, are you still in the need of a Dutch translation?
Sure, so far German, English and Estonian language is supported by default. Just translate DE.php or EN.php (what ever fits best) to NL.php. Please send me a PM once you are done and I will add your translation to the module.

Quote from: D72
... Nice module, but for a beginner... a pain in the ass...
Fully agree. The snippet started with a few options but has grown over time. Any kind of help (e.g. with the README file etc.) is therefore welcome. Sometimes it is hard for a "developer" to write a documentation which fits the needs of the "end users".

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: eazybaker on May 08, 2009, 08:04:37 AM
Hi,

@eazybaker:
Quote from: eazybaker
Yes Estonia language file exists for the WebsiteBaker backend and its EE not EST,so i made mistake,sry abot that
Strange, I found no EE.php in the WB /language folder. But anyway, thanks for your contribution  :wink:
Regards Christian

Yes,becaue i didnt looked into website backer languages folder before :wink:

i found this http://en.wikipedia.org/wiki/Estonian_language and there are only et,and est,but i have seen ee also on many translated scripts,so i think its ok :-)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 08, 2009, 08:52:23 AM
Hi,

@eazybaker: WB is following the ISO 3166-1 (http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) language codes (2 characters).

Regards Christian
Title: Anynews v0.94 released
Post by: doc on May 08, 2009, 03:49:21 PM
Hello,

just released v0.94 of Anynews (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218) which includes the Dutch language file and the Dutch README (http://addons.WebsiteBaker.org/media/readme_files/anynews_readme_nl.html) file contributed by the forum member Dave (ak D72). Funny to see a Dutch README before a German one  :-)

Dave, thank you very much for your support - highly appreciated.

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Deleen on May 20, 2009, 02:59:35 PM
Hello,

i am also start to use anynews in my project. By the way - these picture Problem is also on my side.
Soon as i have a Picture in the short test it is break. I put the outputfilter to "false" and i try with "true" and allow <img>-tag.

I have already the newest version. I saw - this problem was nemes in the tread - but i couls not found real solution. So please - can somebody help?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Deleen on May 20, 2009, 03:08:48 PM
Forgot my problem - i found a asolution, the character setup was to short - is news leght was 50 - if i set it heigher, it works :) .

Greats, Kathleen
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 26, 2009, 03:56:50 PM
Hello,

just released v1.00 of the Anynews code snippet on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).
The English Readme (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) file is up to date, the Dutch one needs to be updated.

Changes:
The latest version includes a new display options ($display_option = 3) which uses jQuery and some JQuery-Plugins developed by Ariel Flesler (http://flesler.blogspot.com/) to display news with the Coda Slider Effect (http://jqueryfordesigners.com/demo/coda-slider.html).

To use this option, one needs to add an additional code line into the index.php file of your template.
Code: [Select]
<?php include_once(WB_PATH . &#39;/modules/anynews/coda-slider.inc.php&#39;); ?>
This mode does also work with Javascript disabled, but without visual effect in that case.

Have fun
Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on May 26, 2009, 04:16:07 PM
Sounds great,

The latest version includes a new display options ($display_option = 3) which uses jQuery and some JQuery-Plugins developed by Ariel Flesler (http://flesler.blogspot.com/) to display news with the Coda Slider Effect (http://jqueryfordesigners.com/demo/coda-slider.html).

Do you have a demo of this one somewhere? (could use it for a new article on my site)

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on May 26, 2009, 05:40:00 PM
Hi Ruud,

seems jqueryfordesigners. com had some server problems. Tried it some seconds ago and the demo seems to work again.: http://jqueryfordesigners.com/demo/coda-slider.html

The Anynews Coda Slider output is very close to the one posted at jqueryfordesigners. com. Just give it a try on a local test environment, it isn´t that much work to set it up  :-)

Regards Christian

P.S.: In case it does not work, I can send you a link with the pure HTML files for the Coda Slider demo.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Luisehahne on May 26, 2009, 05:49:59 PM
Hi,

or look at this

YCodaSlider 3.0

Copyright (c) 2009 Massimiliano Balestrieri
Examples and docs at: http://maxb.net/blog/

greetings
Dietmar
Title: Anynews v1.10 released
Post by: doc on May 31, 2009, 03:05:03 PM
Hi,

just released v1.10 of the Anynews code snippet on the WebsiteBaker Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).
The English Readme (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) file is up to date, the Dutch one is outdated and needs to be updated.

Applied changes:
Added some more default placeholder which can be used in the output (e.g. {DISPLAY_NAME}, {USERNAME}, {GROUP_TITLE} ... The full list of placeholders available can be found in the template file: custom_output_display_mode_4.htt ($display_mode:=4).

More advanced feature:
The function parameter $show_publish_date was replaced with the new parameter $custom_placeholder which allows users to define their own placholder variables by regular expression. If the regular expression matches, additional placeholders are avaialbe for usage in the template files. Details about this can be found in the README file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html).

If you have used $show_publish_date = false to hide the publish dates, just remove   the placeholder {PUBLISH_WHEN} from your template filed (folder /htt) to achieve the same effect.

Example:
Code: [Select]
$custom_placeholder:= array('IMG_LINK' => '%img%', 'MY_VAR' => '#(test)#i')
The code above searches the long and short news content for optional image tags (%img%) and text string 'test' (#(test)#i). Assuming, the news long text field contains two image tags and both, short and long text field contains the string 'test', the following additional placeholders can be used inf the template files:
Code: [Select]
LONG_IMG_LINK_1, LONG_IMG_LINK_2
SHORT_MY_VAR_1, LONG_MY_VAR_1

User defined variable names (e.g. MY_VAR turns into: PREFIX_MY_VAR_INDEX, where PREFIX is LONG/SHORT for long or short content field).

Have fun
Christian
Title: Anynews and DHTML
Post by: mylesk42 on June 02, 2009, 11:34:05 AM
Hi everybody,

Has anyone tried to have a News scroller in DHTML to show news via the AnyNews module and to keep the linking to the news itself ?

Regards
Title: Re: Anynews and DHTML
Post by: doc on June 02, 2009, 05:47:14 PM
Hi,

first of all, please try to raise your question in the correct module thread. The module thread (https://forum.WebsiteBaker.org/index.php/topic,409.msg86508.html#msg86508) for discussion are normally linked on AMASP or the WebsiteBaker Addons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218).

Now to your question. Have you checked out the Coda Slider stuff integrated since Anynews v1.00? This should give you a good starting point for Javascript driven News output. If you have already a working JS script, maybe post the link so other users may be able to pick it up and to create a working demo.

Regards Christian

Maybe a forum administrator can move this thread into the Anynews thread.
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on June 02, 2009, 06:09:26 PM
OK ... done.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on June 03, 2009, 07:53:07 PM
Hi there,

Checked the help files and the forum but still didn't got the answer I was looking for.

Simple question:

Do I have to create a template for every language in which I want to place the news items for that specific language?

I have 3 languages, 3 different 'latest news' pages in each language. The automatic translation for the 'read more' button does work fine.

But do I have to create a template for every language because otherwise you see all the languages underneath each other in the latest news section.

May be I'm overlooking something because in the HELP files there is no mentioning about creating a template for every language in order to show only the specific language and not all languages underneath each other.

The
Code: [Select]
array(3,4) thing only publics certain groups, not certain languages.

Any help would be appreciated.

Greetz,

Boudi
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on June 03, 2009, 08:30:39 PM
Hello Boudi,

same problem was reported in the German forum part today  :wink:

You have to use the Page Language Feature of WB (Settings -> Advanced Options -> Page Language) and assign each page to e.g. German, English etc.

Than you can use the following construct (DE, EN Support) in your template index.php file to get things working:
Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;))  {
  
if (LANGUAGE == &#39;DE&#39;)  {
    
displayNewsItems(2,3,-1,1,&#39;de&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;);
  
} else {
        
displayNewsItems(3,3,-1,1,&#39;en&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;); 
  
}

?>


Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on June 03, 2009, 08:37:47 PM
Hi Christian,

Thnx for your quick answer :)

But is there still that issue with these setting? -> Settings -> Advanced Options -> Page Language.

If you do so there will be problems when doing a search; the flags of other countries then will dissapear.

I thought I mentioned this behaviour for some months ago.

I just did a check on a multilanguage WB 2.7 website and enabled the Settings -> Advanced Options -> Page Language. After that I did a search and the flags dissapeared. After I turned this option off again the flags stayed intact after a search.

That's why I always turn this option off: Settings -> Advanced Options -> Page Language when creating multilanguage WB sites.

or am I doing seriously wrong over here?  :?

Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on June 03, 2009, 09:13:22 PM
Hi Boudi,

Quote from: boudi
But is there still that issue with these setting? -> Settings -> Advanced Options -> Page Language.
Done some checks recently with the Language Switcher Snippet (flags), show_menu2 and the latest WB version (from SVN trunk) and have not run into any problems with the search yet.

Don´t now if this is fixed or not. Maybe it is best to start another thread to discuss about this issue, as this is not a "Anynews" specific tasks.

Good luck
Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on June 03, 2009, 09:26:08 PM
Hi,

Well, again I ran into problems when enabling the Page Language and setting the news pages in their languages; they dissapear from the menu. (eg; the german button "aktuell" does not show up in the German menu)

Besides that your piece of coding didn't do anything. (didn't show the news at all)

I'm sure I'm doing something wrong over here but for the moment I'm still figuring out what exactly.

So I will brainstorm further this evening and tomorrow. When I get the job done I will let you know  :wink:

Thnq anyway for your help.

Greetz,

Boudi
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on June 03, 2009, 10:23:05 PM
It seems working now. (with the Page Language disabled  :wink:) but still 1 problem: the website contains 3 languages:

Dutch/English/German

I used your example and tried to implement a 3rd language. But then I end up with a blank screen. But it actually does work with 2 languages.

How must I change this code into 3 languages? (Unfortunately I'm not a php coder so I can't 'see' how to achieve this)

Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;))  {
  
if (LANGUAGE == &#39;DE&#39;)  {
    
displayNewsItems(2,3,-1,1,&#39;de&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;);
  
} else {
        
displayNewsItems(3,3,-1,1,&#39;en&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;); 
  
}

?>


Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on June 03, 2009, 10:33:17 PM
Hi Boudi,

guess you have a coding error and the error_reporting is set to E_NONE, thats why you see a blank screen.
You can do it via if, elseif, else statement, or to learn something different with a switch statement as shown below.

Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;))  {
  
switch(LANGUAGE) {
    case &
#39;DE&#39;:
        
displayNewsItems();
        break;
        
    case &
#39;EN&#39;:
        
displayNewsItems();
        break;
        
    default:
        
displayNewsItems();
        break;
    }

?>


Note:
Please check the Function parameter you pass over to Anynews. Arguments like 'none' and 'disabled' are no valid function parameters. Details can be found in the Anynews README file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) (section Example for a customized call).

Regards Christian
Title: Re: Code Snippet: Display news items, anywhere
Post by: Boudi on June 03, 2009, 10:43:02 PM
Christian,

Your code just did the job. Thnq very much!  :lol:

I got it working with the -> Settings -> Advanced Options -> Page Language disabled.

So no page language configuration is needed.

Again thnq!  :-)

Greetz,

Boudi

PS: If you would like to see this result then I would be happy to pm you.

Title: Code Snippet: Anynews
Post by: doc on June 07, 2009, 09:11:03 PM
Hello,

please note that I have suspended my support for the "Anynews" code snippet effective June 07, 2009. If someone wants to develop or maintain this code snippet any further, please feel free to do so, but keep in mind  that the module is licensed under GNU GPL (http://www.gnu.org/licenses/gpl.html).

The last stable version (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218) of the module can be found on the WebsiteBaker Addons Repository.

Regards Christian (doc)
Title: Re: Code Snippet: Display news items, anywhere
Post by: snooze on July 08, 2009, 01:10:11 AM
Why is there no New Topic button?

That's not my actual question. This simple. Would someone please post step-by-step instructions to get Anynews working. I have the latest version installed on WB 2.7. I realize there are help files and web pages, but there seem to be steps left out and I can't bridge the gap.

I see that there's lots of options, but I want to see it working before getting fancy.
Title: Re: Code Snippet: Display news items, anywhere
Post by: D72 on July 08, 2009, 01:14:16 AM
Why is there no New Topic button?

could be me... but this is a Topic with discussions and not a forum where you can find subjects like where we are right now. In topics it's not allowed to add a new topic. Or am i really in the need of some beauty sleep...
Getting to bed any way right now.  :mrgreen:

cheers

gr
Dave
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on July 17, 2009, 11:47:44 AM
Quote
please note that I have suspended my support for the "Anynews" code snippet effective June 07, 2009. If someone wants to develop or maintain this code snippet any further, please feel free to do so, but keep in mind  that the module is licensed under GNU GPL.

As Doc stopped maintaining this snippet I hope there is one who will further support this.

Testing 2.8 RC1 I noticed some confusing things with German Language (see image).
I suppose that is has to do with the work that was done on the news module reffering to validation.
Maybe the anynews snippet has to be adapted. What is confusing me is that the same letter is shown right and wrong.
BTW in the news module/page itself  all signs are ok.

Anyone with an idea?

rgds

erpe

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:10:34 PM
As Doc stopped maintaining this snippet I hope there is one who will further support this.

As I am using this snippet on a page I am going to update once 2.8 is released, I can take support for AnyNews. But please keep in mind that my own modules will have priority when I have to split my time. :roll: At the moment, the final release of EasyMenu has highest priority.

If there are open requests at this time (apart from the one erpe posted above), please let me know. I'll see what I can do.
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on July 17, 2009, 12:25:04 PM
Hi WebBird

nice to hear that you will care about this snippet.

Thanks

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:25:17 PM
Anyone with an idea?

Yes. :-D

The news text is shortened. Shortening happens by counting the chars and cutting off the rest when the point of "max chars" is reached.

At this point, there is no single char, but a HTML Entity -> &szlig;

This entity is not recognized, so the text is cut off anyway.

Please send me the complete text and the settings you're using. I will try to correct this issue.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:26:15 PM
nice to hear that you will care about this snippet.

Well, it's in my own self-interest. :wink:
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on July 17, 2009, 12:28:49 PM
What is confusing me is that the same letter is shown right and wrong.

Seems to me that this is happening because the Snippet is cutting the Text after a predefined number of characters.
And it could be that the snippet stops counting by using the HTML Code, not its output in the Frontend.

So you have umlauts and you have 'ß'.
In HTML the Ä for example has - as you know - looks like &Auml; .
Let's consider the snippet is counting the characs in HTML so it will maybe count up to "&Aum" and then the Output is going nuts.

It's just what I can see through the picture.

Regards,
Stefek

//EDIT, Bianka was faster :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:32:26 PM
//EDIT, Bianka was faster :-D

But your explanation was helpful. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on July 17, 2009, 12:45:16 PM
Sometimes it is so easy.
Thanks WebBird and Stefek.

That was it.

I changed the number of signs and was done.

rgds

erpe

PS: Is this something that has to be changed?  :?  If yes, let me know what you want to know.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:48:31 PM
I think it would be nicer if the break would not be in the middle of a word. :-D So this will not happen again. Should be fixed.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 12:50:50 PM
My English is perfect, isn't it* :lol: :lol: :lol: :lol: :lol: :lol: :lol:
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on July 17, 2009, 12:52:17 PM
Hi,

similar issue is when usign the option to truncate the text output at a certain length but allow tags as already discussed in this thread or another thread dealing with Any News.

Another thing which could be fixed with a next version is to get rid of the jQuery stuff in the module folder (used for Anynews Coda Slider effect). Once WB 2.8 gets released, the jQuery stuff could be replaced with the WB 2.8 core jQuery routines.

Cheers Doc

P.S.: Webbird nice to see that you will maintain the snippet in the future :-)
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 01:05:55 PM
Thanks, doc, for the hints. I will take care of it.

I just added a wordwrap2() function that hopefully will fix the text cut issue. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 01:07:31 PM
P.S.: Webbird nice to see that you will maintain the snippet in the future :-)

Well, it's easy to take care of a module I use myself. :wink: Thank you for this great snippet!
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on July 17, 2009, 01:17:08 PM
Maybe someone wants to try this hack:

include.php, Line 217:

Code: [Select]
// leave original line, but comment out
// $row['content_short'] = substr($row['content_short'], $start_pos, $max_news_length) . '...';
// after, add:
        $row['content_short']
              = wordwrap2(
                    substr( $row['content_short'], $start_pos ),
                    $max_news_length
                ) . '...';

At end of file, BEFORE ?>, add:

Code: [Select]
function wordwrap2( $str, $width = 75, $break = '\n', $cut = true ) {
  $str = html_entity_decode( $str ); //first decode
  $out = wordwrap( $str, $width, $break, $cut ); //now wordwrap
  $out = htmlentities( $out ); //re-encode the entities
  $out = str_replace( htmlentities( $break ), $break, $out ); //put back the break
  // return the first line
  $temp = explode( $break, $out );
  return $temp[0];
}

Now, when using the cut-param...

Example:
Code: [Select]
DisplayNewsItems( 0, 10, 50 );

...the short text should be cut after 50 chars, but without breaking the last word. (So, the resulting length will be shorter than 50 in most cases.)
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on July 17, 2009, 01:43:03 PM
Hi WebBird

passt  :-D

Danke für die schnelle Hilfe.

Gruss

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on August 13, 2009, 03:27:50 PM
I just released v1.11.

+ fix: break at word boundaries instead of fixed $max_news_length
+ added French language (FR.php) contributed by forum member Guillaume (ak creatile)

Download at AMASP: http://www.websitebakers.com/pages/code-snippets/listings/anynews.php?lang=EN
Title: Anynews
Post by: doc on August 13, 2009, 04:53:42 PM
Hi,

latest version now also available at the Add-ons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php#id_218), thanks WebBird.

Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on August 14, 2009, 10:42:14 AM
Thank you, doc. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on August 21, 2009, 09:58:08 PM
can we specify : THAT news feed

like, i'v got a page that dont need no "groups" but got 2 news, can i specify check that feed ?
Title: Re: Code Snippet: Display news items, anywhere
Post by: crnogorac081 on August 21, 2009, 11:03:32 PM
You can remove:

Code: [Select]
       $table = TABLE_PREFIX . 'mod_news_posts';
        $sql = "SELECT * FROM `$table`
            WHERE `active` = '1'
This line    --------->        AND $sql_group_id 
            AND (`published_when` = '0' OR `published_when` <= '$server_time')
            AND (`published_until` = '0' OR `published_until` >= '$server_time')
            AND $sql_not_older_than
            ORDER BY $sql_order_by $sql_sort_order
            LIMIT 0, $max_news_items";


from sql query :)


---  ooooups, I for get to mention that its in include.php file :)
cheers
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on August 24, 2009, 04:56:18 PM
i'll test, but as I can see, it will show ALL news, i want a particular news "section" from a singular "page" and not all news sections and pages
Title: Re: Code Snippet: Display news items, anywhere
Post by: crnogorac081 on August 24, 2009, 05:22:27 PM
I dont understand, you want to display specific news from specific group ?

like:

Group 15
-News 1
- news 2    < this one
- news 3
- news 4    < and this one ?

right ?
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on August 24, 2009, 05:36:19 PM
Every post also has a section_id (and page_id) stored in the table.

Adding a
WHERE `section_id` = $my_wanted_section_id
in the query is what you want.

$my_wanted_section_id should be added to the function parameterlist.

Ruud
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on August 24, 2009, 05:39:46 PM
done it.

i've modified include.php of version 1.11 to make the function do this :
Code: [Select]
function displayNewsItems(
        $section_id = 0, $group_id = 0, $max_news_items = 10, $max_news_length = -1, $display_mode = 1, $lang_id = 'AUTO',
        $strip_tags = true, $allowed_tags = '<p><a><img>', $custom_placeholder = false,
        $sort_by = 1, $sort_order = 1, $not_older_than = 0)
see? first item is section....

i've also added this :
Code: [Select]
sanitizeUserInputs($section_id, 'i{0;0;999}');just after the line with this
Code: [Select]
sanitizeUserInputs($group_id, 'i{0;0;999}');
i've added this :
Code: [Select]
// check for multiple sections or single section values
        if (is_array($section_id)) {
            // SQL query for multiple groups
            $sql_section_id = ' AND `section_id` IN (' . implode(',', $section_id) . ')';
        } else {
            // SQL query for single or empty groups
            $sql_section_id = ($section_id) ? 'AND `section_id` = \'' . $section_id . '\'' : '1';
        }
just after this code :
Code: [Select]
// show all groups if group_id is array which contains 0
        if (is_array($group_id) && in_array(0, $group_id)) $group_id = 0;

        // check for multiple groups or single group values
        if (is_array($group_id)) {
            // SQL query for multiple groups
            $sql_group_id = '`group_id` IN (' . implode(',', $group_id) . ')';
        } else {
            // SQL query for single or empty groups
            $sql_group_id = ($group_id) ? '`group_id` = \'' . $group_id . '\'' : '1';
        }
and finaly, modified the sql for this :
Code: [Select]
$sql = "SELECT * FROM `$table`
            WHERE `active` = '1'
            AND $sql_group_id
            $sql_section_id
            AND (`published_when` = '0' OR `published_when` <= '$server_time')
            AND (`published_until` = '0' OR `published_until` >= '$server_time')
            AND $sql_not_older_than
            ORDER BY $sql_order_by $sql_sort_order
            LIMIT 0, $max_news_items";

now i can specify the news i want to show it's in section "53", meaning the section of this particular page, so i dont have to make groups specific to show only this news and the 4 mores "news" modules in other section wont show on my anynews call.

p.s. : i've included a retranslation of the include.php and FR.php language, it wasn't completed.

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: crnogorac081 on August 24, 2009, 05:41:47 PM
If you  want do display specific news posts, find this lines and replace them with following code:


        /**
         * Work out SQL query for the group_id
         * $sql_group_id:= ($group_id:=0 => '1'; $group_id:=X => `group_id` = 'X'; $group_id:=array(2,3) => `group_id` IN ('2,3'))
         */
        // show all groups if group_id is array which contains 0
        if (is_array($group_id) && in_array(0, $group_id)) $group_id = 0;

        // check for multiple groups or single group values
        if (is_array($group_id)) {
            // SQL query for multiple groups
            $sql_group_id = '`post_id` IN (' . implode(',', $group_id) . ')';
        } else {
            // SQL query for single or empty groups
            $sql_group_id = ($group_id) ? '`post_id` = \'' . $group_id . '\'' : '1';
        }


this way you can put post id in array..

cheers
Title: Re: Code Snippet: Display news items, anywhere
Post by: Luckyluke on August 25, 2009, 04:39:20 PM
Hi,

I've got a multi language site.
In the template I use following code:

Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;))  {
  
if (LANGUAGE == &#39;NL&#39;)  {
    
displayNewsItems(2,3,-1,1,&#39;nl&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;);
  
} else {
        
displayNewsItems(3,3,-1,1,&#39;en&#39;,true, &#39;<p><a><img>&#39;,&#39;none&#39;,4, 3,&#39;disabled&#39;); 
  
}

?>

The language setting is enabled.
Still, I see all the news from all languages.
It's a bit the same problem like this here (on previous page (https://forum.WebsiteBaker.org/index.php/topic,409.msg86837.html#msg86837)) but it doesn't work in my situation. I use WB 2.8. Is this a WB 2.8 specific problem?

Grtz,
Luc
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on August 25, 2009, 04:45:34 PM
language is only for the template, not the language of the news.

it seams to me you'd need to take my last version of include and ad the news sections of each languages.
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on August 25, 2009, 05:11:09 PM
Hi Luc

you have to create a group for each language and then specificly call the group in the anynews call.
The language-file  is for the readmore link and the date.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on August 25, 2009, 07:15:19 PM
Guys ... have a look at the last Version of the anynews snippet ... it parses the URL for the "language" like in the Tutorial Setup ... this way it should work.

@Luc: Do you have the "language" in the URL exactly like in the anynews parameter and is it shown as well in the URL if you open the news page?

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: Luckyluke on August 25, 2009, 10:22:36 PM
Quote from: erpe
you have to create a group for each language and then specificly call the group in the anynews call.
he language-file is for the readmore link and the date.

@Erpe,
This is a solution but not the best one.

Quote from: kweizel
Do you have the "language" in the URL exactly like in the anynews parameter and is it shown as well in the URL if you open the news page?

@Kweizel
I'm sorry, I don't understand what you mean.
But in WB 2.7 my site (http://www.kisstory.be) shows something like ?language=NL in the URL. I see it's gone after I update the site to WB 2.8
I updated the site with the news-module. In my new template I will use anynews with 3 languages.

Grtz,
Luc
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on August 26, 2009, 07:24:41 AM
It seems like only the newspage is missing that language. But anyway, from my understanding the language extraction should work anyway. I'll give it a try as well later on.

cheers

Klaus
Title: Re: Code Snippet: Display news items, anywhere
Post by: Luckyluke on August 28, 2009, 12:41:00 PM
A solution is an extra parameter with the section-ID.
So you can choose the appropriate section according to the language you want.
I don't think this is a big adjustment? But a very good one.

Grtz,
Luc
Title: Question from the very beginning
Post by: bikerider on September 02, 2009, 07:11:13 AM
Hi folks,
It seems that I have a very stupid question - but I didn't find anyone with the same problem. I've got this anynews-snippet
Code: [Select]
<?php 
        
if(function_exists(&#39;display_news_items&#39;)) {
          
display_news_items(05501"""mehr lesen""aktuell gibt es keine news..."false);
        } else {
          echo &
#39;Requires code snippet anynews (WB addons repository) to display news here.&#39;;
        
}
      
?>
and I have news - called (you won't belive it) news. But what ever I do - the only thing shown is: "Requires code snippet anynews (WB addons repository) to display news here." Of course the Snippet is installed correctly as module. What's wrong here? Any Ideas? Language problems? The site is in german...

Thank you very much,
Patrick
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on September 02, 2009, 07:39:36 AM
Hi,

if you are using the latest version of Anynews from the WB Repository, you need to adapt your code as the Function call has changed from: display_news_items to displayNewsItems. So simply replace the two strings in your code and it should work.

This is also the right order of function parameters (flags) are described in the README file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) distributed with Anynews.

Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: bikerider on September 02, 2009, 08:35:59 AM
that's it - didn't remark that...  :oops:

thank you very much!!
Title: Re: Code Snippet: Display news items, anywhere
Post by: bikerider on September 02, 2009, 09:38:57 AM
hm, that brings up another problem. when I use the function display_news_item (which is of course not working anymore) the snippet [[RandomImage?dir=header]] works fine.
But when I use the function displayNewsItem I have a problem with the [[RandomImage?dir=header]]-Snippet:  the pictures aren't shown anymore instead the function is displayed as "[[RandomImage?dir=header]] ". What's the problem here? anybody else has that?
And by the way: the news-portlet stays empty: http://www.bikeride.ch/wb/pages/events.php

Code of template:
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<?php page_title(); ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php if(defined(&#39;DEFAULT_CHARSET&#39;)) { echo DEFAULT_CHARSET; } else { echo &#39;utf-8&#39;; }?>" />
<meta name="description" content="<?php page_description(); ?>" />
<meta name="keywords" content="<?php page_keywords(); ?>" />
<link rel="stylesheet" type="text/css" media="screen,projection,print" href="<?php echo TEMPLATE_DIR?>/layout4_setup.css" />
<link rel="stylesheet" type="text/css" media="screen,projection,print" href="<?php echo TEMPLATE_DIR?>/layout4_text.css" />
<title>Multiflex-3 Update-2 / Overview</title>
</head>
<!-- Global IE fix to avoid layout crash when single word size wider than column width -->
<!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
<body>
<body>
<!-- Main Page Container -->
<div class="page-container">
<!-- For alternative headers START PASTE here -->
<!-- A. HEADER -->
<div class="header">
       <div class="nav2">
      <!-- Navigation item -->
<?php if(SHOW_MENU) { /* Only shown menu if we need to */ ?>
    <?php show_menu2(0SM2_ROOTSM2_STARTSM2_PRETTY, &#39;<li [if(class==menu-current){id="menu-current"}]>[a]<span>[menu_title]</span></a>&#39;); ?>
    <?php ?>
    </div><!-- A.2 HEADER MIDDLE -->
  <div class="header-middle">
     [[RandomImage?dir=header]]
    <!-- Site message -->
    <div class="sitemessage"> </div>
  </div>
  <!-- A.3 HEADER BOTTOM -->
  <div class="header-bottom">

  </div>
  <div class="header-breadcrumbs">

  </div>
  <!-- B. MAIN -->
  <div class="main">
    <!-- B.1 MAIN NAVIGATION -->
    <div class="main-navigation">
      <!-- Navigation Level 3 -->
      <div class="round-border-topright"></div>
      <h1 class="first">Men&uuml;</h1>
      <!-- Navigation with grid style -->
      <?php show_menu2(0,      SM2_ROOT+1SM2_CURR+1SM2_PRETTY, &#39;<dt>[a][menu_title]</a>&#39;, &#39;</dt>&#39;, &#39;<dl class="nav3-grid">&#39; , &#39;</dl>&#39;);?>
     
    </div>
    <!-- B.2 MAIN CONTENT -->
    <div class="main-content">
      <!-- Pagetitle -->
      <h1 class="pagetitle"><?php echo PAGE_TITLE?></h1>
      <!-- Content unit - One column -->
      <div class="column1-unit">
              <?php page_content(); ?>
      </div>
    </div>
    <!-- B.3 SUBCONTENT -->
    <div class="main-subcontent">
      <!-- Subcontent unit -->
      <div class="subcontent-unit-border-orange">
        <div class="round-border-topleft"></div>
        <div class="round-border-topright"></div>
        <h1 class="orange">latest news</h1>
        <?php 
        
if(function_exists(&#39;displayNewsItems&#39;)) {
          
display_news_items(05501"""mehr lesen""aktuell gibt es keine news..."false);
        } else {
          echo &
#39;Requires code snippet anynews (WB addons repository) to display news here.&#39;;
        
}
      
?>

      </div>
    </div>
  </div>
  <!-- C. FOOTER AREA -->
  <div class="footer">
    <p><?php page_footer(); ?></p>
  </div>
</div>
</body>
</html>

 :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: aldus on September 02, 2009, 09:51:17 AM
Hello bikerider

I'm pretty sure that there are error-messages if you try to set the PHP-Error-Reporting-Level to "E_ALL".

Some copy and paste errors, as the function is named "displayNewsItems" ..

Code: [Select]
<?php 
if(function_exists(&#39;displayNewsItems&#39;)) {
    
displayNewsItems05501"""mehr lesen""aktuell gibt es keine news..."false);
} else {
    echo &
#39;Requires code snippet anynews (WB addons repository) to display news here.&#39;;
}
?>



Regards
Aldus
Title: Re: Code Snippet: Display news items, anywhere
Post by: bikerider on September 02, 2009, 11:27:43 AM
 :oops: sorry - twice...

thank you so much!!!
Title: Re: Code Snippet: Display news items, anywhere
Post by: snark on September 05, 2009, 12:44:50 AM
Anyone who knows wether I can use the anynews for the mediablog module
Title: Re: Code Snippet: Display news items, anywhere
Post by: micklan on September 05, 2009, 12:35:20 PM
Hi!

Why i receive the "&rsquo;" syntax in news instead of  " ' " character ?

Thanks you!
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 11, 2009, 11:21:04 AM
I´ve a problem with allowed tags and didn´t find a solution:

The tag-brackets (<,>) will be replaced with "&lt;" or "&gt;". So, if I allow some tags, the sourcecode is shown in the output.

I use wb2.8 and the newest version of anynews.
 
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 11, 2009, 11:28:05 AM
Have you tried the 'strip_tags' and 'allowed_tags' options of the displayNewsItems() method?

Code: [Select]
strip_tags...         true:=remove tags from short and long text (default:=true); false:=don´t strip tags
allowed_tags...        tags not striped off (default:='<p><a><img>')

See included help files for details.
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 11, 2009, 01:04:45 PM
Hi WebBird!

Yes, I did. This is my snippet in a code-section:

if (function_exists('displayNewsItems')) {
    displayNewsItems(2, 2, 200, 5, DE, true,'<p><a><img>', 1, 0);
}

I also tried "false" instead of "true". The problem is the same.

Do you see any mistake?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 11, 2009, 01:40:14 PM
Cannot reproduce this error. Use "false" instead of "true" and wrap DE in quotes, please.

Code: [Select]
if (function_exists('displayNewsItems')) {
   displayNewsItems(2, 2, 200, 5, 'DE', false,'<p><a><img>', 1, 0);
}

Also, you use a custom template, so please try to replace 5 with 1 for testing. (Which means "details".)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on September 11, 2009, 04:30:17 PM
Hi,

maybe consider to write your anynews function calls as follows (helps to keep track of the various parameters).

Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;)) {
   
displayNewsItems($group_id 2
      
$max_news_items 2$max_news_length 200
      
$display_mode 5$lang_id = &#39;DE&#39;,
      
$strip_tags false$allowed_tags = &#39;<p><a><img>&#39;, 
      
$custom_placeholder false
      
$sort_by 4$sort_order 1$not_older_than 0
   
);
}
?>

You should check $display_mode (5 uses a custom template) and the last two parameters.

Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 11, 2009, 05:56:44 PM
Hi Doc & WebBird,

thanks for your help. I´ve tested your solutions, changed true to false, but the problem stays on. Could it have something to do with the installed php-version?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 14, 2009, 12:55:35 PM
Could it have something to do with the installed php-version?

Which is...?

Is the HTML correct on the News page itself?
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 15, 2009, 09:47:36 AM
Yes, I´ve made no changes in the html-code on news-section. It´s a fresh wb-installation. The php-version is 4.3.9.
I know, that php5 is required for wb 2.8., but exept of anynews it works without any problems.
Title: Re: Code Snippet: Display news items, anywhere
Post by: joep on September 15, 2009, 11:16:04 AM
I have a question.

I use this code:
Code: [Select]
displayNewsItems(array(10,11, 12, 13, 14), 5, 0, 0, false);I don't know much abouth anynews yet!!

What i trie to achief is a block with new items from several groups, showing only the title of the post.

So not the date, or the dots on the bottom. And not the title (Latest News).

It worked with this code:
Code: [Select]
$group = 9; // Specify the Group(id) you want to read the news from

global $database;

$query = "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group ORDER BY position DESC LIMIT 0, 3;";

/*This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10. The first number defines the starting point, and the second the max/end of the results */

$error = mysql_error();
if (!$result = mysql_query($query)) {
  print "$error";
  exit;
}

while($data = mysql_fetch_object($result)){
  $title = $data->title;
  $id = $data->post_id;
  $link = $data->link;
  echo '<li><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a>'.$short.'</li>'; // the loop

}
echo "</ul>"; // end of the loop

the problem with this code is that it only works with one group.

the link to my page is :
http://www.studiozi.com/wb

Thanq in advanced



Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 15, 2009, 12:48:29 PM
Yes, it works only for one group. (Or use 0 for "get from all groups".)

What is the question? :roll:
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 15, 2009, 12:49:05 PM
Yes, I´ve made no changes in the html-code on news-section. It´s a fresh wb-installation. The php-version is 4.3.9.
I know, that php5 is required for wb 2.8., but exept of anynews it works without any problems.

I've tried with PHP 4.4.9, but I still can't reproduce the error. Can you show us?
Title: Re: Code Snippet: Display news items, anywhere
Post by: joep on September 15, 2009, 06:17:55 PM
My question is.

Is it possible to use multiple groups. for example group 3 and 4.
I have 8 groups.
7 of them i want to use.

Maybe i can use somkind of array??
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on September 15, 2009, 06:30:31 PM
@joep:
You can define all groups ($group_id = 0), a single group ($group_id = x) or a collection of groups ($group_id = array(3,4)). Details about the possible function parameters are provided in the Readme file (http://addons.WebsiteBaker.org/media/readme_files/anynews_help_en.html) of the module. A function call with two groups can be found in section "Example for a customized call:" of the Readme.

Please make sure you are using the latest version of anynews.

Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 16, 2009, 09:32:38 AM
Hi WebBird,

no, I can´t for the moment, it´s not public yet. But I made some screenshots, where you can see, what happens.


[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 16, 2009, 10:10:09 AM
Well, on the screenshot the strip_tags param is set to true, which means "strip all tags", and the lang_id is still not enclosed in quotes. ;)
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 16, 2009, 10:34:19 AM
It makes no difference, if I change the parameter from true to false. Language in quotes or not is all the same. I think it has to do with the server-setup.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 16, 2009, 10:50:00 AM
Yes, I'd say it's the most probable explanation. Anyway, I don't know what to look for. :|
Title: Re: Code Snippet: Display news items, anywhere
Post by: aldus on September 16, 2009, 11:41:03 AM
Hello

As far as i can reproduce this bug it has to do within the max-char restriction, e.g. 200 chars,
in the short-message as the function "wordwrap2" converts htmlentities ... so the brakets became
"&lt;" and "&gt;" - also the quotes to &quote ...

To avoid this i've add
Code: [Select]
<?php
 $restore 
= array (
    &
#39;&lt;&#39; => "<",
    
&#39;&gt;&#39; => ">",
    
&#39;&quote;&#39; => "\""
);
$temp[0] = str_replace(array_keys($restore), array_values($restore), $temp[0]);
?>

to the function "wordwrap2" in the bottom of the include.php,
but i'm pretty sure that were are more elegant ways to solve this.

Kind regards
Aldus


[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 16, 2009, 12:27:06 PM
Ah. This also explains the problem "micklan" has with &rsquo;. Funny that I can't reproduce it... I'll try to find a solution. Thank you very much Aldus!!!
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 16, 2009, 01:49:33 PM
I also found that it is ... uhm ... "not nice" if there are any opening HTML tags in the remaining text, so I worked on a solution to close these tags, too. I'm not very happy with the code, but if it works, it's better than leaving it as is.

Can someone please do some tests with the include.php attached?

Edit: Removed attachment
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 22, 2009, 10:19:54 AM
Hi WebBird,
I have tested your include.php an it works as you explained. Many thanks for that.
It´s better than before, but not a real solution for the problem. Now it cuts all news-entries even if to long html-commands found in only one news-entry.

I don´t know how to make it, but the anynews-function "max_news_length" should not count the characters of html-tags and not replace the brackets in principle.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 22, 2009, 10:23:14 AM
This is much more effort I can find the time for at the moment. :roll:
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on September 23, 2009, 07:46:29 PM
Hi,

did a quick Google search (http://www.google.de/search?hl=de&source=hp&q=php+truncate+text+but+not+html+code&btnG=Google-Suche&meta=) and found some working code examples (within the first 10 matches or so).

Doc

Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 23, 2009, 07:51:57 PM
I will have a look at it when I have some free time. (Not within the next weeks.)

Edit: Please take a look at version 1.12. Is this okay?

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on September 25, 2009, 05:44:24 PM
Hi WebBird,

thanks for the new version, but I can´t see a difference. It´s the same behavior as in 1.11:

The short-text is only shown correctly on frontpage, when the number of caracters are set high enough to show the hole short-text. If the short-text has more caracters than set in the code-secton, HTML-brackets are shown on frontpage.

Vielleicht nochmal auf deutsch, weil verständlicher: Ich sehe zu 1.11 keine Änderung. Die Kurztexte werden über das anynews-snippet nur dann korrekt dargestellt, wenn die Anzahl der Zeichen so hoch eingestellt wird, dass auf jeden Fall der gesamte Kurztext damit abgedeckt wird.  Irgendwie passiert der Fehler also beim Zählen der Zeichen und Abschneiden des Kurztextes.
Das Problem ist, dass man ja dem Anwender schlecht vorschreiben kann, bloß keine Formatierungen im Kurztext vorzunehmen.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on September 28, 2009, 10:20:47 AM
Can you provide me a complete test case, please? (Post "Short Text" as HTML Code here for Copy&Paste.)
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on October 02, 2009, 11:08:55 AM
Hi WebBird,

that is the anynews-snippet in my code-section:

echo "<h4>Neueste Beitr&auml;ge</h4>";
if (function_exists('displayNewsItems')) {
    displayNewsItems(2, 2, 260, 5,'DE' ,'true' ,'<p><a><img>' , 1, 0);
}


and here is the html-output:

<h4>Neueste Beitr&auml;ge</h4><div class="anynews">

<h5>Demokratie, Verfassung, Interessenvermittlu ng</h5>

<p><p><img width="50" hspace="5" height="57" align="left" alt="" src="http://www.politik.uni-osnabrueck.de/cms/media/marx.jpg" />Was unter dem Begriff Demokratie zu verstehen ist, dar&uuml;ber gehen nicht nur im Alltagsverst&auml;ndnis die Meinungen auseinander. Auch in der Wissenschaft gibt es ganz unterschiedliche Vorstellungen. <a href="http://www.politik.uni-osnabrueck.de/cms/pages/de/forschung/politik-der-deutschen-vereinigung/kampf-um-die-finanzierung-der-deutschen-einheit.php">Die Begriffe numerische Demokratie,</a> deliberative Demokratie und Verhandlungsdemokra tie bezeichnen <a href="http://www.politik.uni-osnabrueck.de/cms/pages/de/forschung/politik-der-deutschen-vereinigung/kampf-um-die-finanzierung-der-deutschen-einheit.php">prinzipiell unterschiedliche</a> Verfahren zur Herstellung und Legitimation verbindlicher kollektiver Entscheidungen.</p></p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/demokratie-verfassung-interessenvermittlung-7.php">weiterlesen</a></p>
<hr>
<h5>Im Osten nichts Neues </h5>
<p><p><a href="http://www.spiegel.de" target="_blank">Die Berichte der Bundesregierung zum Stand der Deutschen Einheit vermitteln eine ambivalente  Botschaft</a>.  Nur  wer  sie  in  Serie  liest,  erkennt  einen  seit  Jahren  anhaltenden Grundtenor. Er besagt, dass es, abgesehen von einer Vielzahl gefeierter Einzelprojekte, nichts  Neues  zu  berichten  gibt:  Stillstand  im  Osten  lautet  letztlich  das  Fazit.</p></p>

<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/im-osten-nichts-neues-6.php">weiterlesen</a></p>
<hr>
</div>


This works great, but if I reduce the length to 250 I get only the Headlines, no teaser-text:

The output with length 250:

<h4>Neueste Beitr&auml;ge</h4><div class="anynews">

<h5>Demokratie, Verfassung, Interessenvermittlu ng</h5>

<p>...</p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/demokratie-verfassung-interessenvermittlung-7.php">weiterlesen</a></p>
<hr>
<h5>Im Osten nichts Neues </h5>
<p>...</p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/im-osten-nichts-neues-6.php">weiterlesen</a></p>
<hr>
</div>

I have installed your actual version 1.12.



Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on October 03, 2009, 11:58:35 AM
The 8th param is wrong.
($custom_placeholder    false:= none (default), array('MY_VAR_1' => '%TAG%#', ... 'MY_VAR_N' => '#regex_N#' ...)

I think you confounded with #9, $sort_by.

This works fine for me:

Code: [Select]
if (function_exists('displayNewsItems')) {
   displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 5,
       $lang_id = 'DE',
       $strip_tags = false,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );
   //displayNewsItems(57, 87, 260, 5,'DE' ,'true' ,'<p><a><img>' , 1, 0);
}
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on October 06, 2009, 10:41:24 AM
Hi WebBird,
thanks for your help. I´ve tested your code, but there is no difference. I´ll wait for the next version.

Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on October 06, 2009, 10:49:53 AM
Hi Webbird

the new code is working for me...........

Thanks.

erpe

Title: Re: Code Snippet: Display news items, anywhere
Post by: joep on October 06, 2009, 03:00:41 PM
Hello people.

I've got a problem with the LINK to the news page.

I've got this script:

Code: [Select]
displayNewsItems(array(15, 16, 17, 18, 19), 5, 1, 2, NL,
  true, '<p><a><img>', false,
  2, 1, 0);

This works fine!!

The only problem is when i click a menu item, it doesn't link to the specific news page, but the overview page.

Code: [Select]
<div class="anynews">
<ul>
<!-- BEGIN news_block -->
<li><a href="[b]{LINK}[/b]">{TITLE}</a></li>
<!-- END news_block -->
</ul>
</div> {LINK}

The link in this code does that..

Anyone knows how to fix this??

Thnq
Joep Muijres
Title: Re: Code Snippet: Display news items, anywhere
Post by: Luisehahne on October 07, 2009, 12:40:06 AM
Quote
<li><a href="{LINK}">{TITLE}</a></li>

b tag is not allowed there

Dietmar
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on October 07, 2009, 09:38:46 AM
Hi,

as Dietmar mentioned, try to add the <b> tag to the allowed tags.
In addition I would suggest to use the following function call, which makes it much more obvious, for what the various parameter are for.

Code: [Select]
<?php
displayNewsItems
(
  
$group_id = array(1516171819),
  
$max_news_items 5
  
$max_news_length 1,
  
$display_mode 2,
  
$lang_id = &#39;NL&#39;,
  
$strip_tags true,
  
$allowed_tags = &#39;<p><a><img><b>&#39;,
  
$custom_placeholder false,
  
$sort_by 2
  
$sort_order 1
  
$not_older_than 0); 
?>


Also check the settings for max_news_length which is currently set to 1 and the setting for the language, which should be wrapped in quotes 'NL' instead of NL :-)

Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on October 07, 2009, 01:43:50 PM
I´ll wait for the next version.

Which next version?  :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on October 07, 2009, 01:46:40 PM
Hi,

as Dietmar mentioned, try to add the <b> tag to the allowed tags.

But Dietmar meant that <b> is not allowed in the href attribute (by the HTML standard), apart from adding it to the list of allowed tags. ;)
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on October 12, 2009, 06:22:59 PM
Hi,

the latest Version of Anynews v1.13 (AMASP only) includes an updated English Readme (http://www.websitebakers.com/media/amasp_uploads/anynews_help_en.html) file. The examples in the README file make now use of the function parameter to make it more obvious what the different parameters are for :wink:

Doc

P.S.: Apart from the Readme file, no new functions were added
Title: Re: Code Snippet: Display news items, anywhere
Post by: mikejd on November 06, 2009, 03:51:03 PM
I have installed this snippet on a website and I am experiencing some odd behaviour which someone may be able to explain.

The length of the text quoted in the display can be set in the function call to a particular number of characters. I have noticed that this number appears to include any html tags in the short text entry eg if for instance a particular string is tagged as say h4 - <h4>xxxxxxxxxxx</h4> the count includes the <h4> and if the number, say 15, is less than the total number of characters, 20 in this case, the closing tag isn't included. This can result in a serious error in the html code for the page and cause major problems with the overall page display.

Has anyone else noticed this? Is there any solution apart from not using formating in the short text entry? In which case the FCK editor should not be available for that input box as it encourages editors to use it.

Any comments appreciated.

Mike
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on November 06, 2009, 05:01:53 PM
I have addressed this issue above. Please make sure that you have the current version. If you do, please give an URL where to look at the problem.
Title: Re: Code Snippet: Display news items, anywhere
Post by: artifaction on November 10, 2009, 11:27:06 AM
I have a question i really hope someone can help me with.

If I add a image in the "short" section of a news item I can get that to show in anynews, but the problem is that it doesnt look good at all.

I want it to look like this.
http://www.magnuslofdahl.com/img_share/anynews_format.jpg

Is this possible? and how, where do I start.

This is the page I want to change, the news section at the bottom.
http://www.stylingutbildningen.se/

Please some advise would have been worth alot.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on November 10, 2009, 11:37:06 AM
I get an error message with the second link.

You can create a custom layout by editing the "custom_output_displ ay_mode_4.htt" file in the htt subfolder of AnyNews. All AnyNews placeholders are described there. You can also add your very own template file to the htt subfolder. See the help file for more information about this.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Franck707070 on December 10, 2009, 03:58:25 PM
Hi there,

I have a little problem.

I wanted to add a bit of code in order not to display the title "Nouvelles" and the corresponding DIV when there's no news to display. I tried both ways below without success. The echo doesn't display at all, even if there's some news to display and I don't understand why...  :?

First try:

Code: [Select]
<!-- Display News -->
<?php
if (function_exists(&#39;displayNewsItems&#39;)) {
    
$test displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
    if (
$test != "")
    {   
        echo &
#39;<div id="menunews" style="display:block;">&#39;;
        
echo &#39;<a href="http://prix-excellence.com/pages/nouvelles.php">Nouvelles</a>&#39;;
        
displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
        echo &
#39;</div>&#39;;
    
}
}
?>

Second try:

Code: [Select]
<!-- Display News -->
<?php
if (function_exists(&#39;displayNewsItems&#39;)) {
    
$test displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
    if (
$test != "")
    {    
?>

        <div id="menunews" style="display:block;">
        <a href="http://prix-excellence.com/pages/nouvelles.php">Nouvelles</a>
        <?php
        displayNewsItems
(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
        
?>

        </div>
        <?php
    
}
}
?>

advTHANKSance
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 10, 2009, 04:15:14 PM
https://forum.WebsiteBaker.org/index.php/topic,15579.msg100790.html#msg100790
Title: Re: Code Snippet: Display news items, anywhere
Post by: Franck707070 on December 10, 2009, 10:03:57 PM
Nice, thank's a lot!

Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 11, 2009, 10:18:46 AM
I think the trick you needed to know is the usage of ob_start() etc. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 11, 2009, 01:26:14 PM
Hello,

I wonder if there is no way to output just the date (w/o time) with this snippet.
Or did I overseen a parameter to call?

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 11, 2009, 02:13:05 PM
See $LANG['DATE_FORMAT'] in the language module(s)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 11, 2009, 02:27:35 PM
Could you please explain a little further?
Where to see and how to change in the snippet.

I hardcoded a change for myself in the inlcude.php of the snippet and produced a new PLACEHOLDER for the output. It works good for me, but I think there is a better way without changing the snippet files?

Regards,
Stefek
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 11, 2009, 03:55:35 PM
There are language modules (DE.php, ...) in the languages subfolder of the module. Just open one of your choice and set the array key DATE_FORMAT to the format you wish to use.

There is no parameter.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Stefek on December 11, 2009, 04:57:31 PM
Thanks Bianka!
Title: Re: Code Snippet: Display news items, anywhere
Post by: Mirens on December 12, 2009, 08:19:30 PM
Hello people, I just downloaded this snippet and made it work like I want. Since I will be using this mostly in Serbia I made language modification because of clients. So here it is... name the file RS.php (Republic of Serbia) our internet domain is .rs and because of our characters save it as UTF-8 or whatever.
Thank you again!

Code: [Select]
<?php
/**
 * Serbian language file for the code snippet: anynews
 *
 * This code snippets grabs news from the WB news module database
 * and displays them on any page you want by invoking the function
 * displayNewsItems() via a page of type code or the index.php 
 * file of the template.
 *
 * This file contains the Serbian language output.
 * 
 * LICENSE: GNU General Public License 3.0
 * 
 * @author        Christian Sommer
 * @copyright    Christian Sommer (c) 2007-2009
 * @license        http://www.gnu.org/licenses/gpl.html
 * @version        1.00
 * @platform    WebsiteBaker 2.7
*/

// Serbian module description
$module_description    = &#39;WebsiteBaker modul za prikazivanje novosti na bilo kojoj stranici vašeg web site-a. Funkcija modula može biti implementirana u sam template ili putem code sekcije. Detalji i pomoć oko korišćenja ovog modula mogu se naći u samom modulu na linku <a href="{WB_URL}/modules/anynews/help/help_en.html" target="_blank">README</a>&#39;;

// declare module language array
$LANG = array();

// Tekstualni prikaz izlazne forme modula
$LANG[0] = array(
    &
#39;TXT_HEADER&#39;        => &#39;Najnovije vesti&#39;, 
    
&#39;TXT_READMORE&#39;        => &#39;detaljnije&#39;, 
    
&#39;TXT_NO_NEWS&#39;        => &#39;Vesti ne postoje u bazi.&#39;,
    
&#39;TXT_NEWS&#39;        => &#39;Novosti&#39;, 
    // English date/time format: (9:12 PM, 10/20/2008)
    
&#39;DATE_FORMAT&#39;        => &#39; | d.m.Y. - H:i&#39;,        
    
&#39;TXT_REQUIREMENTS&#39;    => &#39;Greška, Anynews možete koristiti samo sa WebsiteBaker verzijom 2.7 ili novijom.&#39;,        
);

?>

Title: Re: Code Snippet: Display news items, anywhere
Post by: Mirens on December 13, 2009, 12:29:08 AM
Hm I maybe have a problem  :| its probably something easy but...

This is my code
Code: [Select]
$group_id = 0, $max_news_items = 10,$max_news_length = 251, $display_mode = 1, $lang_id = 'AUTO',
$strip_tags = true, $allowed_tags = '<p><a><img>', $custom_placeholder = false,
$sort_by = 1, $sort_order = 1, $not_older_than = 0)
with $max_news_length = 251, whole message is there no nead for cutting even image from short story is there, and everything is nice like on next picture (I put this psichedelic colors for easyer understanding)
Gray color is background color for all the <p> in div anynews.
(http://www.hammerproduction.net/newsa/maxlength251.jpg)
After that I made a change in $max_news_length = 250 , so the script have to cut the message and make it shorter. I change setting just for 1 character! from 251 to 250.
The image disapear from short story.
Link of that image is counted in that 250 characters (you can see there is no 1 character missing but the half of text), and gray zone iz gone, so I guess <p> disapered somehow.
(http://www.hammerproduction.net/newsa/maxlength250.jpg)
I take back the maxlength setting to fit the whole short story or put it to -1 and everything is like on picture 1 nice and clean.

Is there some way I can make this to work or I'm just stupid :)
Sorry for long post but I wanted to bring as more info as I can.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Mirens on December 14, 2009, 12:47:35 AM
Ok, I'm trying to fix this I never used PHP, I saw today the output part of html. When script is using new added code for shortening the long text:
// New code; break at word boundary
html output is displayed like this
Code: [Select]
&lt;img width=&quot;220&quot; height=&quot;60&quot;only text is displayed no image because html dont understand this...

When script doesnt shorten the txt i got the code like this and everything is fine
Code: [Select]
<p><img width="220" height="60"So... I figured out that decoding is somewhere lost, I searched on google for PHP decode... and added one line of code in script
Code: [Select]
function wordwrap2( $str, $width = 75, $break = '\n', $cut = true ) {
  $str = html_entity_decode( $str ); //first decode
  $out = wordwrap( $str, $width, $break, $cut ); //now wordwrap
  $out = htmlentities( $out ); //re-encode the entities
// I added
//  $out = html_entity_decode( $out );
// end of my adding
  $out = str_replace( htmlentities( $break ), $break, $out ); //put back the break
  // return the first line
  $temp = explode( $break, $out );
  return $temp[0];
}

?>
Now everything is nice BUT now when there is &nbsp; in html code it is displayed with some strange ascii black and white questionmark. And now I'm stuck again...
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 14, 2009, 10:42:36 AM
Thank you very much for the serbian language file. I will include it with the next release.


You may want to try the truncate() method you can find at

http://209.85.135.132/search?q=cache:byzMdc5_BK8J:https://trac.cakephp.org/ticket/2306+php+truncate+string+html&cd=2&hl=de&ct=clnk&gl=de&client=firefox-a

(Google cache, as the ticket seems to be not available anymore.)

Please note that you will have to edit the truncate()-call, too. (Line 222 ff)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Mirens on December 14, 2009, 01:57:52 PM
Thank you for your answer, oh... I'm not so familiar with PHP jet, what I manage do to is delete this line from the include.php code
Code: [Select]
$str = html_entity_decode( $str ); //first decode
and add this line
Code: [Select]
$out = html_entity_decode( $out );
&nbsp; is now converted in blank space, all lattin characters are there, all cyrilic characters are there all pictures from short story are there.
But I dont think I can just like that delete some line of the code and everything work.
So please tell me if this what I did is not safe or something.
Title: Re: Code Snippet: Display news items, anywhere
Post by: hansis on December 19, 2009, 11:24:28 AM
Hello!

I manage my events with module "Event Calendar". At the entry site I want to display the next 3 events.
Is this possible with Any news Item?

thx.
hansi
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 20, 2009, 03:40:23 PM
No. It's not called NextEvents. :-D

Edit: You may want to try this droplet. It creates a month calendar and takes/links the events from Event Calendar 1.8c.

https://forum.WebsiteBaker.org/index.php/topic,15895.msg105131.html#msg105131

See it in action:

http://www.bonsai-nrw.de/cms/
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 20, 2009, 03:41:12 PM
But I dont think I can just like that delete some line of the code and everything work.
So please tell me if this what I did is not safe or something.

Well, if it works for you, just leave it. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: hansis on December 21, 2009, 11:00:12 AM
recht herzlichen Dank

jetzt spiele ich noch mit CSS :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: dbs on December 21, 2009, 12:39:38 PM
@webbird: auf der bonsai-seite scheint die foldergallery schön sortierbar zu sein.
sind da schon neuerungen in verwendung?

dbs
Title: Re: Code Snippet: Display news items, anywhere
Post by: geasy on December 27, 2009, 03:02:54 PM
Hi all

Just installed anynews and I'm astonished by all the functionalities includes: Cool! Congratulation to this great module.

Now, I have two little questions regarding this module:

1. Parameters
I have opened a "code section" on one of my pages. If I put in the code:

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems();
}

everything works fine. As soon as I change to eg.

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(display_mode = 1,);
}

it is not working anymore (means there is no news shown on the page anymore). What am I doing wrong here?  :?

2. No long content

Some of my news do not have a long content but the "read more" link is shown in any case. Is there a possibility that the "read more" link is only shown if there is a long content for this particular news?

Many thanks in advance for your help.

Claudio

Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 28, 2009, 09:48:38 AM
@webbird: auf der bonsai-seite scheint die foldergallery schön sortierbar zu sein.
sind da schon neuerungen in verwendung?

Nö. Von Hand in der Datenbank gefummelt. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 28, 2009, 09:57:41 AM
As soon as I change to eg.

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(display_mode = 1,);
}

it is not working anymore (means there is no news shown on the page anymore).

There are two errors in that code:

1. The parameters are positional. This means you will have to add all parameters _before_ $display_mode, too.
2. You missed the $ in front of display_mode.

See here:

Code: [Select]
displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 5,
       $lang_id = 'DE',
       $strip_tags = false,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );

So, in your case, the correct code would be:

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 1
   );
}

Just use the default values for the params you do not wish to set explicitly. (See docs for defaults.)

2. No long content

Some of my news do not have a long content but the "read more" link is shown in any case. Is there a possibility that the "read more" link is only shown if there is a long content for this particular news?

This is hardcoded in the output template. So there's no simple way to do this at the moment. You could only remove that part from the template, but it will be missing then if there's long content, too.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 28, 2009, 03:53:14 PM
So here's v1.14 for testing. :-D

* fix: replaced function to truncate long text with a (hopefully) better one
* added Serbian language file (RS.php) contributed by forum member "Mirens"
* no "read more" link shown if there's no "long text" in the news entry

Note: If you wish the "read more" link to appear in any case, remove the <!-- BEGIN readmore_link_block --> and <!-- END readmore_link_block --> block markers from the template.

I will upload this version to AMASP when I'm sure it works, so please check it out. :-D

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: geasy on December 29, 2009, 11:39:28 AM
Wow, cool, herzlichen Dank für's schnelle Anpassen!

That looks perfect to me.

Regarding the missing "$" in my code: I just copied the code from the http://www.websitebakers.com/media/amasp_uploads/anynews_help_en.html (http://www.websitebakers.com/media/amasp_uploads/anynews_help_en.html). There are no "$" in the code. 
However, many thanks for your help with that!

Claudio
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 29, 2009, 12:52:34 PM
Hm, maybe they (the $) are not really important, while the position of the param is, anyway. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on December 29, 2009, 01:02:52 PM
I've upgraded AnyNews at AMASP.

http://www.websitebakers.com/pages/code-snippets/listings/anynews.php?lang=EN
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on January 21, 2010, 03:32:34 PM
Hi Bianka

after registration on a site I get the following parsing error::
Fatal error: Call to undefined method wb::preprocess() in /var/www/web128/html/modules/anynews/include.php on line 194   

WB 2.8
Anynews 1.12

It is curious, that this happens only after registration, the site is running well on all other pages (seems that the page stops while redirectimg, the registration is successful).

Any idea?

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 21, 2010, 04:05:18 PM
Uhm, what do you mean saying "registration"?
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on January 21, 2010, 04:24:44 PM
mmhh

use the registration function with a droplet login box.

Hope this helps.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 22, 2010, 11:04:06 AM
I tried to reproduce this error, but it works for me. Tested with "All CSS" template. If you have a non-production copy of the site, try to use another template.

You can also try to add this code to include.php:

Code: [Select]
       // register outside variables
        global $wb, $database;

// AFTER ADD
                if ( ! is_object( $wb ) ) {
                    require_once(WB_PATH.'/framework/class.frontend.php');
                    // Create new frontend object
                   $wb = new frontend();
                }
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on January 22, 2010, 12:46:04 PM
Included posted code in include.php of anynews (1.14.) but no effect.
Same error appears.

Any additional idea?

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 22, 2010, 01:08:39 PM
Hi,

the Anynews function call shown in the info section of AMASP seems to be corrupt. Think it has to do with the allowed tags <a>. Think a small bug in the edit dialoge of the module used.
http://www.websitebakers.com/pages/code-snippets/listings/anynews.php

Maybe the missing $ can be added to the README files with the next update.

Regards Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on January 22, 2010, 01:40:20 PM
Yes, I noticed it yesterday too.
Hope that Aldus will correct this soon.

Thanks for posting.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: erpe0812 on January 22, 2010, 04:03:53 PM
@all who are interested in this:
https://forum.WebsiteBaker.org/index.php/topic,409.msg110386.html#msg110386

It was a bug in xfast_Template_2 and had nothing to do with anynews.........tho ugh it seems to have on the first impression.

Thanks to Webbird and Aldus for quick help.

rgds

erpe
Title: Re: Code Snippet: Display news items, anywhere
Post by: aldus on January 25, 2010, 10:10:38 AM
Hm ...
I've update the modul "informati0n" at AMASP to leave html-source inside a
pre tag uninterpreted, e.g.
Code: [Select]
<pre class="code">
&#x3c;ul id="myGallery" class="image-overlay">
&#x3c;li>
&#x3c;a href="http://www.domain.tld">
      &#x3c;img alt="Image 1" src="yourimages/Image1.jpg"/>
      &#x3c;div class="caption">
        &#x3c;h3>My Image&#x3c;/h3>
        &#x3c;p>click for more info&#x3c;/p>
      &#x3c;/div>
    &#x3c;/a>
  &#x3c;/li>
&#x3c;/ul>
</pre>

by replacing the opening braked < to his hex-entity &#x3c; .
So you can (now) display source inside the description/information fields
like shown at
http://www.websitebakers.com/pages/code-snippets/various/image-overlay.php

Also replaced the $ char to avoid PHP-Conflicts in examples, like "var $xyz is not defined" ...

Regards
Aldus
Title: Re: Code Snippet: Display news items, anywhere
Post by: kleo on January 25, 2010, 07:42:48 PM
I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

More thanks!

Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 27, 2010, 09:42:34 AM
I've been asking about possibility to view the posts in "most commented" order:

https://forum.WebsiteBaker.org/index.php/topic,16548.0.html (https://forum.WebsiteBaker.org/index.php/topic,16548.0.html)

I quess this is possible with Anynews, by modifying include.php. My coding skills are limited, so could somebody give me a hint?

Code: [Select]
sort_by...    5:= number of comments
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 27, 2010, 10:35:43 AM
Hmmm... This requires a more complex SQL query, as the comments are stored in another table. You will have to modify the query (lines 127ff), or add another one especially for the comments count.

Are there any other ones interested in this feature?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 27, 2010, 12:20:46 PM
Please try the include.php attached. Be sure to make a backup copy of the original include.php before trying this one.

Edit: Removed attachment. New version available at AMASP. http://www.websitebakers.com/pages/code-snippets/listings/anynews.php
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 27, 2010, 08:34:13 PM
Seems to work. It would be good to display number of comments after the date in news list.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 28, 2010, 10:54:21 AM
Seems to work. It would be good to display number of comments after the date in news list.

I thought you would suggest this. Try COMMENTS markup. ;) (Custom Template)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 28, 2010, 01:36:10 PM
Just can't understand how to add number of comments to custom templates  :oops:
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 28, 2010, 01:52:26 PM
Just add {COMMENTS} to the template you use at the position you wish.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 28, 2010, 02:21:12 PM
Not working. Do I need to add some custom placeholder also?

I tried adding
Code: [Select]
<tt>COMMENTS: </tt>{COMMENTS}<br /> in custom_output_displ ay_mode_4.htt
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 28, 2010, 02:54:35 PM
Do you USE that template? (Param $display_mode in displayNewsItems call.)
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 28, 2010, 03:24:55 PM
Maybe this helps...

If you do not set $display_mode, the default is 'detailed output'. The template file for 'detailed output' is htt/detailed_output.htt.

Here's the content of that file:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>

<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>

Just add the markup {COMMENTS} to that file. Example:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>
Number of comments: {COMMENTS}<br />
<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 28, 2010, 06:05:10 PM
Tried that, but it is not displaying the number. Only "Number of comments: " and then blank
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 28, 2010, 06:24:07 PM
Hm. Works for me. :?

Just saw that the text is outside the loop. Try this:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>
<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
Number of comments: {COMMENTS}<br />
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 28, 2010, 07:48:36 PM
No help. I think that variable {COMMENTS} is not set anywhere. Do I need some custom placeholder? Or does it need to be set in include.php. Or am I totally lost here?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 29, 2010, 10:47:46 AM
It is already set in the new include.php. But maybe I did not upload the last version. :?

Please download the new version 1.15 at AMASP and try it again.

http://www.websitebakers.com/media/amasp_uploads/anynews_v1.15.zip

Edit: Checked it out, it was missing in the include.php I provided for testing. I'm sorry. :|
Title: Re: Code Snippet: Display news items, anywhere
Post by: Turskis on January 29, 2010, 12:02:08 PM
Now it's working. Thanks, this was a very important feature for me!
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on January 29, 2010, 01:26:32 PM
@Webbird: Would be nice if you could also maintain/update the README file with new releases. The latest implemented options seems to be missing. Also the README on AMASP and Add-ons point to an outdated version.

Regards Doc
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 29, 2010, 02:48:50 PM
Yepp. Will write that on my Todo list. But I need help with the NL readme. :roll:
Title: Re: Code Snippet: Display news items, anywhere
Post by: seagull on January 31, 2010, 11:20:56 AM
Maybe i overlooked it, but when i use displayanynews with displaymode=2(only the newstitle as link) and having newsitems with only shorttext the resulting page displays the longtext wich is empty, so only the header and the footer are displayed.
Am i doing something wrong or is this the way the snippet should work?(only with long text)

@webbird, i would like to help you with the Dutch translation.

Jan
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on January 31, 2010, 03:16:46 PM
Great, Jan, thank you! Just take the help_en.html to see what's new there and missing in help_nl.html.

I'll take a look at displaymode 2 tomorrow. Promise. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on January 31, 2010, 07:07:59 PM
Hello All,

when I use the AnyNews call...

Code: [Select]
if (function_exists('displayNewsItems')) {
   displayNewsItems(
       $group_id = 2,
       $max_news_items = 10,
       $max_news_length = -1,
       $display_mode = 1,
       $lang_id = 'auto',
       $strip_tags = true,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );
}

... on a standalone CODE page, News teasers display fine within my template.

But when I pack the same into a droplet, say "Anynews", and place it on a WYSIWYG page with [Anynews]], the News teasers appear outside (above) my WB template.

Any idea what I'm missing? I walked through this whole thread but couldn't find a clue...  :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on February 01, 2010, 10:33:39 AM
Do you use "return" to return the content, or just the call? The call does an "echo", what's not what you're after when using a droplet.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on February 01, 2010, 10:38:28 AM
Just the call, as shown in my code quote.

What would the droplet syntax look like with a return?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on February 01, 2010, 10:41:29 AM
You will have to "catch" the output with ob_start()... etc and return it.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on February 01, 2010, 10:45:50 AM
Try:

Code: [Select]

$output = NULL;
if (function_exists('displayNewsItems')) {
   ob_start();
   displayNewsItems(
       $group_id = 2,
       $max_news_items = 10,
       $max_news_length = -1,
       $display_mode = 1,
       $lang_id = 'auto',
       $strip_tags = true,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );
   $output = ob_get_clean();
}
return $output;


You may set $output to something else but NULL, if you wish to print out an error message if the Anynews call fails, for example.

Edit: Fixed code.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on February 01, 2010, 11:01:49 AM
Thanks! But...

I copied your code 1:1 to a droplet, but when used on a page, it doesn't return anything.... :?
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on February 01, 2010, 11:16:49 AM
Woops, sorry, it's ob_get_clean(), not ob_end_clean().
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on February 01, 2010, 11:23:59 AM
Ah, now it's working. Thanks a lot, WebBird!
Title: Re: Code Snippet: Display news items, anywhere
Post by: seagull on February 01, 2010, 09:03:55 PM
@WebBird

Quote
Maybe i overlooked it, but when i use displayanynews with displaymode=2(only the newstitle as link) and having newsitems with only shorttext the resulting page displays the longtext wich is empty, so only the header and the footer are displayed.
Am i doing something wrong or is this the way the snippet should work?(only with long text)

It's not Anynews that causing this but the newsmodule itself.

For now i modified view.php(at line 450) of the news so that if the $post_long is empty the $post_short is printed otherwise the $post_long should be printed.

thanks, Jan
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on February 02, 2010, 10:00:13 AM
Ah. I misunderstood "resulting page". You meant the page Anynews links to, right? You can open a bug ticket for the news module if you wish. But take a look if it is an already known problem before opening a ticket.
Title: Re: Code Snippet: Display news items, anywhere
Post by: tiesy on February 02, 2010, 05:32:41 PM
I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

More thanks!



This is easy to solve: You have to relace "$group_id" to "$page_id" on every position of the snippet. Tools like "InfoRapid Suchen & Ersetzen" will do this in a few seconds. If you don´t want to overwrite the original-snippet, simply rename it in the info.php to something like "anypagenews". 
Title: Re: Code Snippet: Display news items, anywhere
Post by: sky writer on March 22, 2010, 02:43:24 AM
I've tried searching the forum and this thread, but can't find an answer.

I have a block in my template that currently shows three random news items (from 5 groups).  The anynews code is in my index.php

Is it possible to have anynews show different content (from a single group) in this same block on certain pages?  I know I can add another block and call anynews from a code section, but then the three "global" anynews items AND these specific items would show.  I only want to show the specific anynews items on these pages.

I am trying to avoid having to add an anynews code section for every single page in my site.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on March 22, 2010, 11:18:12 AM
I don't know if I understand you right. You wish to include AnyNews only once, but show the content of different News Sections and/or Groups depending on the current page?
Title: Re: Code Snippet: Display news items, anywhere
Post by: sky writer on March 22, 2010, 04:32:03 PM
I'll try to explain by giving an example.

Let's say I only have three pages (Home, About and Contact), and three news groups (A,B and C).  And I have a right hand column block on all the pages, which is where I want the anynews to display.

On the "Home" and "Contact" pages, I want to show three random news posts, chosen from all three groups (A, B and C).  But on the "About" page, I want to show three random news posts ONLY from Group C.

Currently I have the anynews call in my template index.php, and so I get three random posts pulled from all my groups.  I realize that I can put anynews in a code section on each individual, but in reality I have dozens of pages, and most of them I want to have the same call (random from all groups).  There are only about four pages that I want to have specific info from only one group called.

So, I am wondering if you can have a "global" anynews call in the template index.php, and then somehow over-ride it on certain pages with a 'code section call' on those pages.

Hope this makes more sense.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on March 23, 2010, 10:11:18 AM
You would have to use variables, depending on the page, and use a default (random, in this case) for all pages that don't have a special setting.

So, this is the default, as quoted in the help page:

Code: [Select]
<?php displayNewsItems(
   
$group_id 0,
   
$max_news_items 10,
   
$max_news_lenght = -1,
   
$display_mode 1,
   
$lang_id = &#39;auto&#39;,
   
$strip_tags true,
   
$allowed_tags = &#39;<p><a><img>&#39;,
   
$custom_placeholder false,
   
$sort_by 1,
   
$sort_order 1,
   
$not_older_than 0
   
); 
?>


For "3 random News from all groups" you need to set $group_id to 0, $max_news_items to 3 and $sort_by to 4.

Now let's say that this is the default for all pages with no special settings, but on page "About", you would like to see 3 random News from Group 5. Let's assume that the "About" page has the ID 55.

Code: [Select]
<?php
$this_group_id 
0;
if ( 
PAGE_ID == 55 ) {
    
$this_group_id 5;
}

displayNewsItems(
   
$group_id $this_group_id,
   
$max_news_items 3,
   
$max_news_lenght = -1,
   
$display_mode 1,
   
$lang_id = &#39;auto&#39;,
   
$strip_tags true,
   
$allowed_tags = &#39;<p><a><img>&#39;,
   
$custom_placeholder false,
   
$sort_by 4,
   
$sort_order 1,
   
$not_older_than 0
   
); 
?>



If you have lot's of pages with different settings, it will be easier to use an array instead.

Code: [Select]
<?php
$map_page_to_group 
= array(
    
55 => 5,
    
66 => 6,
);

$this_group_id = isset( $map_page_to_group[PAGE_ID] ) ? $map_page_to_group[PAGE_ID] : 0;

displayNewsItems(
   
$group_id $this_group_id,
   
$max_news_items 3,
   
$max_news_lenght = -1,
   
$display_mode 1,
   
$lang_id = &#39;auto&#39;,
   
$strip_tags true,
   
$allowed_tags = &#39;<p><a><img>&#39;,
   
$custom_placeholder false,
   
$sort_by 4,
   
$sort_order 1,
   
$not_older_than 0
   
); 
?>



Edit: Put this code into your index.php.
Title: Re: Code Snippet: Display news items, anywhere
Post by: sky writer on March 23, 2010, 05:05:31 PM
Thank you so much!  The array approach looks like what I will be needing.  I really appreciate your time and knowledge.
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on March 23, 2010, 05:55:59 PM
I really appreciate your time and knowledge.

Well, I like chocolate very much. :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: sky writer on March 24, 2010, 03:08:37 AM
Your array solution worked perfectly.  Thanks again.  I would send chocolate, but if you're anything like my wife who is Dutch, you prefer the GOOD chocolate to our Canadian MILK variety.  :lol:
Title: Re: Code Snippet: Display news items, anywhere
Post by: WebBird on March 24, 2010, 10:56:27 AM
Please note that I have suspended my support for the "Anynews" code snippet effective March 24, 2010.

If someone wants to develop or maintain this code snippet any further, please feel free to do so, but keep in mind  that the module is licensed under GNU GPL.

The last stable version of the module can be found on the WebsiteBaker Addons Repository.

http://www.websitebakers.com/pages/code-snippets/listings/anynews.php

Regards, Bianka (WebBird)
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on March 26, 2010, 09:42:31 AM
After the Add-On File editor, the next suspension.

Is there any particular reason? Did I miss something "political"?

Did I even bet on the wrong horse by picking WBfor some major projects?  :roll:

I hope not...
Title: Re: Code Snippet: Display news items, anywhere
Post by: BlackBird on March 26, 2010, 11:23:00 AM
Of course, there is a reason, but I don't think that this should be discussed here. :roll: Maybe it helps if I mention that I also have left all WB teams.

Edit: BlackBird = WebBird. My old Forum account was deleted.
Title: Re: Code Snippet: Display news items, anywhere
Post by: doc on March 26, 2010, 03:07:24 PM
Hi,

Quote from: Harry P.
After the Add-On File editor, the next suspension.
Last reported AFE "issue" goes back to 25th July 2009 (Englisch thread). Last "feature request" goes back to 2009.

Some "non AFE related issues" were reported after introduction of WB 2.8.1 RC. Instead of waiting for WB 2.8.1 final to fix the problem, I decided to release an intermediate AFE version, which also fixed some "depracated warnings". In my eyes, AFE reached a "mature" level with v0.80.

As maintainance without specific requests or bug reports from the community is not very attractive to me, I decided to stop my support. Some open requests, like the possibility to edit not only WB files, would have broken my "philosophy" behind AFE and wouldn´t have made it into AFE anyway (which may change with another maintainer). There was nothing I could think off to be added to AFE in the WB 2.x line anyway

That´s basically all I have to say about this topic in the forum :-)

P.S:
However, the experience I gained is transferred into a "standalone" tool (PHP 5.3) with more flexibility (e.g. folder based navigation, definition of any folder you like), more configuration options such as filter, search and basic image transformation (crop, resize, rotate, flip).
Title: Re: Code Snippet: Display news items, anywhere
Post by: Harry P. on March 26, 2010, 04:17:10 PM
Thanks for the info, doc.

Quote
a "standalone" tool (PHP 5.3) with more flexibility

Is that one publicly available?
Title: Re: Code Snippet: Display news items, anywhere
Post by: syamfamily on May 14, 2010, 05:58:04 AM
hello guys...how the way to add group image in anynews?
does anyone know.....please help me....

 :mrgreen: :mrgreen: :mrgreen:
Title: Re: Code Snippet: Display news items, anywhere
Post by: snark on May 28, 2010, 12:30:44 PM
If i put two anynews snippets on one page, both with the coda slider something goes wrong

when click the arrow on one anynews block, both will slide to the next item

is it possible to prevent this?


Title: Re: Code Snippet: Display news items, anywhere
Post by: Argos on June 14, 2010, 01:11:53 PM
I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

Earlier in this thread VotreEspace posted an excellent solution for section_ID support: https://forum.WebsiteBaker.org/index.php/topic,409.msg95799/topicseen.html#msg95799

I think this feature should be added as a built-in option to the module!
Title: Re: Code Snippet: Display news items, anywhere
Post by: kleo on June 14, 2010, 08:28:16 PM
I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

Earlier in this thread VotreEspace posted an excellent solution for section_ID support: https://forum.WebsiteBaker.org/index.php/topic,409.msg95799/topicseen.html#msg95799

Thank YOU!
I think this feature should be added as a built-in option to the module!

I use now a Droplett:
http://www.websitebakers.com/pages/droplets/official-library/navigation/getnewsheads.php

Can you help me to change this droplett with this code?
From your Link:
https://forum.WebsiteBaker.org/index.php/topic,409.msg95799/topicseen.html#msg95799
Title: Re: Code Snippet: Display news items, anywhere
Post by: BlackBird on June 23, 2010, 12:10:32 PM
Yesterday, I was asked for a solution to show the group image with AnyNews. So I created this solution:

File include.php, find line 256 ff:

Code: [Select]
                               // replace the news article dependend template placeholders
$tpl->set_var(array(
'WB_URL'    => WB_URL,
...more code going here...

BEFORE, add:

Code: [Select]
       $group_id = $row['group_id'];
        $image = '';
        if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'))
        {
            $image = '<img src="'.WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'.'" alt="" />';
        }

AFTER, add:

Code: [Select]
'GROUP_IMAGE'     => $image,

Add the {GROUP_IMAGE} markup to the template (.htt file) you're using and you're done.

Edit: You may edit the <img> attribute to suit your needs. (Add a CSS class or something.)
Title: Re: Code Snippet: Display news items, anywhere
Post by: macsmet on June 27, 2010, 02:53:32 PM
Hi there,

There is an error in the latest Anynews (1.16) in the include.php
See this thread: https://forum.WebsiteBaker.org/index.php/topic,18600.0.html (https://forum.WebsiteBaker.org/index.php/topic,18600.0.html)
Solved thanks to Alexandra!!

greetings,

MacSmet
Title: Re: Code Snippet: Display news items, anywhere
Post by: Nyborg on July 13, 2010, 03:33:28 PM
Hi there,

This is a GREAT module of which I am sad I did not find it before now .. :roll:

In the custom .htt files, is it possible to rearrange the {PUBLISHED_WHEN}-{PUBLISHED_UNTIL}, so that they ONLY display the dates in question "(STARTDATE - ENDDATE)" and not as i my case "(STARTTIME, STARTDATE)- (ENDTIME, ENDDATE)"?

Currently it shows: "(11:15 AM, 07/12/2010)- (12:00 AM, 07/25/2010)" and I want to get rid of the time code.

Regards,

Nyborg
Title: Re: Code Snippet: Display news items, anywhere
Post by: snark on July 13, 2010, 07:45:30 PM
have a look at the anynews languagefile

Title: Re: Code Snippet: Display news items, anywhere
Post by: kirk on July 24, 2010, 10:58:46 AM
Hello folks,

i looking for that place where the strip_tag function located.

Especially i need to remove an empty tag: &nbsp; from the short message content of the news modul.

any suggestions?

kirk
Title: Re: Code Snippet: Display news items, anywhere
Post by: kirk on July 25, 2010, 04:54:27 PM
because i find the same issue in the simple page head modul which passed the unwanted empty tag &nbsp; i looked around and find the function str_replace

With this function i can remove selected tags.

So i extended in the simple page head modul include.php the line 103

Code: [Select]
102       $the_description = str_replace('"', '', $the_description);
103       $the_description = str_replace('&nbsp;', '', $the_description);

i couldn't find a matching place in the any news modul to achieve the result like in simple page head.

Is  some one around here who take a look in the any news modul and help me out?


Kirk
Title: Re: Code Snippet: Display news items, anywhere
Post by: D72 on September 19, 2010, 02:01:09 PM
Is there any trick to get something like:
Code: [Select]
$max_title_lenght = 20,Or any given number of course, not just 20 characters.
There is an option $max_news_lenght = 20,
But it would be nice to truncate the title as well so it fits neat in a certain div element.
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on October 01, 2010, 05:44:12 PM
i know language is used for the display, but is there a way taht only news in that language be displayed too ?

that's what I asked my self, and then modify version 1.16a like this :

in include.php
i've added the line :
Code: [Select]
(strtoupper($lang_id) == 'AUTO')?$asked_language=LANGUAGE:$asked_language=strtoupper($lang_id);after the line
Code: [Select]
loadLanguageFile($lang_id);
and the change the lines :
Code: [Select]
   $join   = NULL;
    $fields = '*';
    $group  = NULL;

    if ( $sort_by == 5 ) {
        $join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
        $fields = 't1.*, count(comment_id) AS comment_count';
        $group  = 'GROUP BY t1.post_id';
    }
to :
Code: [Select]
   $join   = 'JOIN `'.TABLE_PREFIX.'pages` AS t3 ON t3.`page_id` = t1.`page_id`';
    $fields = 't1.*, t3.`language`';
    $group  = "AND t3.`language`  = '".$asked_language."'";

    if ( $sort_by == 5 ) {
           $join = 'LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id JOIN `'.TABLE_PREFIX.'pages` AS t3 ON t3.`page_id` = t1.`page_id`';
           $fields = 't1.*, t3.`language`, count(comment_id) AS comment_count';
  $group  = "AND t3.`language`  = '".$asked_language.'\' GROUP BY t1.post_id';
    }

and it worked! now if you ask displaynews in auto on a french page, only news distributed on french pages will display!
I've attach the modified include.php of version 1.16a

modify this post to change the zip file

[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: Xagone on October 09, 2010, 06:04:50 PM
next update need a french language update, the old one is mistranslated.


[gelöscht durch Administrator]
Title: Re: Code Snippet: Display news items, anywhere
Post by: bisun on October 12, 2010, 10:25:06 PM
Just wanted to notify... I use Anynews 1.16a and had problems getting the value of the {COMMENTS} for all sort modes except mode 5. Any other mode showed an empty string as value for number of comments. It seems as the field 'comment_count' only is set for sort mode 5. I fixed this problem on my page by simply remove the if condition in include.php:  :-D

Before:
Code: [Select]
...
$join   = NULL;
$fields = '*';
$group  = NULL;

if ( $sort_by == 5 ) {
    $join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
    $fields = 't1.*, count(comment_id) AS comment_count';
    $group  = 'GROUP BY t1.post_id';
}

/**
 * Perform SQL database query for Anynews
 */
$table = TABLE_PREFIX . 'mod_news_posts';
...
After:
Code: [Select]
...
$join   = NULL;
$fields = '*';
$group  = NULL;

$join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
$fields = 't1.*, count(comment_id) AS comment_count';
$group  = 'GROUP BY t1.post_id'; 
   
/**
 * Perform SQL database query for Anynews
 */
$table = TABLE_PREFIX . 'mod_news_posts';
...

Don't know if only I had a problem with this?
Title: Re: Code Snippet: Display news items, anywhere
Post by: tkche on April 12, 2011, 03:43:21 PM
Hi, Part of my users on the website use Hebrew names which.
whenever using the {DISPLAY_NAME} on anynews template it results in some odd symbols instead of Hebrew characters.
I assume it has something to do with utf8 encoding error. does anyone has an idea of how to fix this?

thanks.
Title: Re: Code Snippet: Display news items, anywhere
Post by: mikejd on May 05, 2011, 01:43:35 PM
I am trying to change the template for this snippet. I have created a new file custom_output_displ ay_mode_5.htt and changed the call in the $display_mode to 5. But it doesn't change the display on the page. I have tried reloading with no effect.

Any suggestions to make it work?

Mike
Title: Re: Code Snippet: Display news items, anywhere
Post by: nick0 on July 05, 2011, 12:12:45 PM
This has been asked before but through all my searching I haven't found an answer to it.

Is there a way to only display the "Read More" if something is entered in the long news box?

I have mostly short news snippets that don't require a long version, so clicking the read more just goes to a blank-ish page.

Many thanks to anyone who can help :)
Title: Re: Code Snippet: Display news items, anywhere
Post by: dbs on July 05, 2011, 01:20:26 PM
there is a way to show the content_short if the conten_long is empty.
https://forum.WebsiteBaker.org/index.php/topic,21671.msg145787.html#msg145787 (https://forum.WebsiteBaker.org/index.php/topic,21671.msg145787.html#msg145787)
Title: Re: Code Snippet: Display news items, anywhere
Post by: maverik on July 05, 2011, 01:22:55 PM
news modul > view.php

search for

Code: [Select]
$post_long = ($post['content_long']);
replace with

Code: [Select]
$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];

######

dbs was faster  :-D
Title: Re: Code Snippet: Display news items, anywhere
Post by: lausianne on September 05, 2011, 04:13:48 PM
Hi,

A bug! Yes, I found one! Probably.

Maybe this helps s.o. else who encounters this problem, maybe s.o. knows a real solution:

With any code such as &auml; in the text, the displayed code "lost" its surrounding <p> tags. Other special characters, like &#269; are no problem. Only "friendly" codes.

Finally, this problem disappeared, when I set $max_news_length to -1, i.e. turned it off.

Cheers,
Ralf.
Title: Re: Code Snippet: Display news items, anywhere
Post by: picas2012 on January 16, 2012, 11:13:45 PM
Hi

Have a problem...i make a website with anynews module and the news are displayed in home page.

I need to show the last news...ok...it´s easy, but if i need to show not the last news, but starting with the last before the last one...understand ?

EX:
i have 4 news
news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

but i want to display only
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

NEVER SHOWS THE FIRST (THEL MOST RECENT)

It´s possible ?

Thanks

Paulo
Title: Re: Code Snippet: Display news items, anywhere
Post by: Ruud on January 16, 2012, 11:57:31 PM
Not without php knowledge.
You would need to modify AnyNews to do that.
Title: Re: Code Snippet: Display news items, anywhere
Post by: jacobi22 on January 17, 2012, 04:20:58 AM
Quote
I need to show the last news...ok...it´s easy, but if i need to show not the last news, but starting with the last before the last one...understand ?

change the LIMIT in the MYSQL-Order in modules/anynews/include.php - Row 170

Look at this code

Code: [Select]
ORDER BY $sql_order_by $sql_sort_order
                        LIMIT 0, $max_news_items";

and change the LIMIT to 1

Code: [Select]
ORDER BY $sql_order_by $sql_sort_order
                        LIMIT 1, $max_news_items";
Title: Re: Code Snippet: Display news items, anywhere
Post by: picas2012 on January 17, 2012, 05:46:05 PM
Hi

Thanks for the replys to my problem

in this case i have another problem...i have news in 2 parts of the site...

if i change the include.php the tag LIMIT, i change in all anynews the LIMIT


one section must be
news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

and in other section must be
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012


Please help me

Thanks
Title: Re: Code Snippet: Display news items, anywhere
Post by: jacobi22 on January 17, 2012, 06:17:40 PM
only one resolution: a new parameter "$min_news_items"  in the function " displayNewsItem()"  in modules/anynews/include.php
the new Parameter is "$min_news_items" at the End - standard is 0

here the "new" function

Code: [Select]
if (!function_exists('displayNewsItems')) {
        function displayNewsItems(
                $group_id           = 0,
    $max_news_items     = 10,
    $max_news_length    = -1,
    $display_mode       = 1,
    $lang_id            = 'AUTO',
                $strip_tags         = true,
    $allowed_tags       = '<p><a><img>',
    $custom_placeholder = false,
                $sort_by            = 1,
    $sort_order         = 1,
    $not_older_than     = 0,
    $min_news_items     = 0
  )        {

and in the mysql-Order

Code: [Select]
$sql = "SELECT $fields FROM `$table` AS t1 $join
                        WHERE `active` = '1'
                        AND $sql_group_id
                        AND (`published_when` = '0' OR `published_when` <= '$server_time')
                        AND (`published_until` = '0' OR `published_until` >= '$server_time')
                        AND $sql_not_older_than
                        $group
                        ORDER BY $sql_order_by $sql_sort_order
                        LIMIT $min_news_items, $max_news_items";

(changed in the last row -> LIMIT $min_news_items, $max_news_items

Now you have a new parameter like

displayNewsItems(array(7,4), 4, 200,1 ,auto,'<img>','<p><a>',false, 1, 2, 0, 1);

if you use 0 or nothing, it shows

news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

if you use 1, it shows

news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

and if you use 2, it shows

news 3 in 13/11/2012
news 4 in 12/11/2012

etc.



Title: Re: Code Snippet: Display news items, anywhere
Post by: carfreak on January 23, 2012, 11:44:51 AM
Geetings all.

i have on the homepage an anynews item with primary news. ( and other groups to put the items in when it is not primary any more )

On several other pages i have put some code to list sertain items.
Code: [Select]
if (function_exists('displayNewsItems')) {
displayNewsItems(
$group_id = 9 );
}

I have several of them.

Now the problem is that on the home page everyting works just fine, when i click "read more" it shows the long content.

now on all other pages when i click "read more" this will appear on the page.


[TITLE] [GROUP_IMAGE]
[PUBLISHED_DATE]
[PAGE_TITLE] >> [GROUP_TITLE]

[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]

[TEXT_BACK]

Can someone explane what is going wrong.

Greetings

Adriaan
Title: Re: Code Snippet: Display news items, anywhere
Post by: picas2012 on January 25, 2012, 01:14:04 AM
Hi

It´s possible to personalize automatic the configuration when i create a page news ?

header, post loop, footer, etc...

I have to change everytime i created a page

Thanks

Paulo
Title: Re: Code Snippet: Display news items, anywhere
Post by: jacobi22 on January 25, 2012, 01:21:05 AM
do you mean the Code fields under NEWS-> Option?

change the code in modules/news/add.php
Title: Re: Code Snippet: Display news items, anywhere
Post by: cwsoft on February 11, 2012, 11:06:09 AM
Hello,

I try to revive the support of the Codesnippet "Anynews" (https://forum.WebsiteBaker.org/index.php/topic,23355.msg). As this thread is quite old, long and somewhat confusing, I started a new one.

Maybe a forum admin may want to make this old thread read only, to highlight the revive of Anynews in the new thread ... Lets see if and how this will work.

Cheers
cwsoft
Title: Re: Code Snippet: Display news items, anywhere
Post by: kweitzel on February 11, 2012, 11:43:56 PM
Done ...

cheers

Klaus