Code Snippet: Display news items, anywhere

pszilard

#127
When I try to use the News snipet and save, I get the following:

QuoteNot 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
Paul Szilard
WB user since Dec 2007:
[url="http://www.remektek.com.au/wb"]http://www.remektek.com.au/wb[/url]
[url="http://photos.remektek.com.au/"]http://photos.remektek.com.au/[/url] for my photo portfolio

pszilard

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,
Paul Szilard
WB user since Dec 2007:
[url="http://www.remektek.com.au/wb"]http://www.remektek.com.au/wb[/url]
[url="http://photos.remektek.com.au/"]http://photos.remektek.com.au/[/url] for my photo portfolio

doc

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

babsy

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.. ? :?

babsy

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

babsy

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!

DGEC

Well, according to the initial posting of the snippet, the parameters are:

QuoteOptional 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:
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.

babsy

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 :)?

babsy

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 :)

kweitzel

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:

ORDER BY posted_when

not tested though!

cheers

Klaus

babsy

#117
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)

babsy

#116
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??

JonH


doc

this should work (without starting and ending PHP tags)
<?php
echo '<div class="news">';
display_news_items();
echo 
'</div>';
?>


Christian

JonH

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.

ruebenwurzel

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

doc

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

JonH

#110
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?

doc

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

JonH

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!

spida

Quote from: DGEC on September 13, 2007, 09:27:15 PM
- 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.

Quote from: DGEC on September 13, 2007, 09:27:15 PM
- 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


tiesy

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".

DGEC

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...

spida

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

DGEC

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?