Welcome, Guest. Please login or register.
March 21, 2010, 06:48:48 AM

Login with username, password and session length
Search:     Advanced search
WB 2.8.1 released!
Download and additional information are available here .
110567 Posts in 15967 Topics by 9310 Members
Latest Member: stevenris10
* Home Help Search Login Register
+  WebsiteBaker Community Forum
|-+  English
| |-+  Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code) (Moderators: Argos, BerndJM)
| | |-+  Code Snippet: Display news items, anywhere
Pages: 1 ... 9 10 [11] 12 13 ... 19 Go Down Print
Author Topic: Code Snippet: Display news items, anywhere  (Read 65539 times)
sparkdigital

Offline Offline

Posts: 254


Once a baker, always a baker!


WWW
« Reply #250 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
Logged
doc

Offline Offline

Posts: 3581


« Reply #251 on: March 03, 2009, 05:53:04 PM »

Hi Konrad,

have a look at the Readme file coming along with Anynews. Guess the last two options sort_order and sort_by are your friend.

Regards Christian
Logged
sparkdigital

Offline Offline

Posts: 254


Once a baker, always a baker!


WWW
« Reply #252 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
Logged
doc

Offline Offline

Posts: 3581


« Reply #253 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
Logged
sparkdigital

Offline Offline

Posts: 254


Once a baker, always a baker!


WWW
« Reply #254 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
Logged
sparkdigital

Offline Offline

Posts: 254


Once a baker, always a baker!


WWW
« Reply #255 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
Logged
doc

Offline Offline

Posts: 3581


« Reply #256 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
Logged
sparkdigital

Offline Offline

Posts: 254


Once a baker, always a baker!


WWW
« Reply #257 on: March 04, 2009, 11:47:10 AM »

Okay, never mind!

K
Logged
daydreamer

Offline Offline

Posts: 149


« Reply #258 on: March 12, 2009, 11:17:33 AM »

Read more links to /index.php on each post not to the actual post?
Logged
doc

Offline Offline

Posts: 3581


« Reply #259 on: March 14, 2009, 08:40:28 AM »

Hi,

Anynews v0.40 is available on the Website Baker Addons repository.

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
Logged
JonH

Offline Offline

Posts: 18


« Reply #260 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:
<?php displayNewsItems(05502
  
'Latest news''read more''No news available',
  
true'<a><img>'true' (d.m.Y)'11); ?>

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)
« Last Edit: March 15, 2009, 07:01:14 PM by JonH » Logged
doc

Offline Offline

Posts: 3581


« Reply #261 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.

Regards Christian
« Last Edit: March 15, 2009, 07:20:32 PM by doc » Logged
JonH

Offline Offline

Posts: 18


« Reply #262 on: March 15, 2009, 07:32:51 PM »

Aaahaaaa! That mouse over trick did the job.
Thank's a lot!
Logged
babsy

Offline Offline

Posts: 299


« Reply #263 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?
Logged
erpe

Offline Offline

Posts: 1738



WWW
« Reply #264 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
Logged

babsy

Offline Offline

Posts: 299


« Reply #265 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
                ));
Logged
erpe

Offline Offline

Posts: 1738



WWW
« Reply #266 on: March 17, 2009, 02:42:30 PM »

What version of anynews do you use?
Logged

babsy

Offline Offline

Posts: 299


« Reply #267 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 Smiley
« Last Edit: March 17, 2009, 02:54:56 PM by babsy » Logged
erpe

Offline Offline

Posts: 1738



WWW
« Reply #268 on: March 17, 2009, 03:02:13 PM »

Yes, that's the template........

Add the link and you are done.

rgds

erpe
Logged

babsy

Offline Offline

Posts: 299


« Reply #269 on: March 17, 2009, 03:16:11 PM »

thanks for you help SmileySmiley
 
Logged
Gitrian

Offline Offline

Posts: 2


« Reply #270 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.
Logged
doc

Offline Offline

Posts: 3581


« Reply #271 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
Logged
Gitrian

Offline Offline

Posts: 2


« Reply #272 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
Logged
doc

Offline Offline

Posts: 3581


« Reply #273 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 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
« Last Edit: March 28, 2009, 12:39:52 PM by doc » Logged
doc

Offline Offline

Posts: 3581


« Reply #274 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 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:
<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 from the Website Baker repository if you have no glue how to modify the Anynews template files.

Good luck
Christian
Logged
Pages: 1 ... 9 10 [11] 12 13 ... 19 Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!