WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
  • Print
Pages: 1 ... 3 4 [5] 6 7 ... 21   Go Down

Author Topic: Code Snippet: Display news items, anywhere  (Read 372466 times)

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #100 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
Logged

spida

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #101 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
Logged

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Code Snippet: Display news items, anywhere
« Reply #102 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?
Logged

spida

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #103 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
Logged

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Code Snippet: Display news items, anywhere
« Reply #104 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...
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #105 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".
Logged

spida

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #106 on: September 19, 2007, 08:51:34 AM »
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

Logged

JonH

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #107 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!
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #108 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
Logged

JonH

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #109 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?
« Last Edit: December 07, 2007, 09:52:36 PM by JonH »
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #110 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
Logged

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8544
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Code Snippet: Display news items, anywhere
« Reply #111 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
Logged

JonH

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #112 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.
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #113 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
Logged

JonH

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #114 on: December 08, 2007, 12:18:12 PM »
Thanks! it works like i planed :)
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #115 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??
« Last Edit: December 10, 2007, 11:35:24 AM by babsy »
Logged

Offline babsy

  • Posts: 337
anynews... acting weird!
« Reply #116 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)
« Last Edit: December 10, 2007, 03:48:11 PM by doc »
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #117 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
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #118 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 :)
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #119 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 :)?
Logged

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Code Snippet: Display news items, anywhere
« Reply #120 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.
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #121 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!
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #122 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
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #123 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.. ? :?
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #124 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
Logged

  • Print
Pages: 1 ... 3 4 [5] 6 7 ... 21   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2