Author Topic: snippet: newslist  (Read 956 times)

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
snippet: newslist
« on: January 25, 2016, 12:27:49 PM »
Hi,

On the weekend I have written a new snippet to display the headlines of a specific news-section. anynews has a mode which might provide a similar functionality, but it didn't find any news-entries in my installation and the module is not maintained anymore (at least that's what I have found in the web).
My new snippet is basically a stripped-down version of the view.php of the news-module, and it displays the headline and publication date only, and visitors can click on the link for further reading.

Currently the snippet is very basic and not very flexible, but it suits my needs. if anyone finds it useful, the package is attached to this post.

Martin

Offline Klimentiy

  • Posts: 12
Re: snippet: newslist
« Reply #1 on: January 25, 2016, 01:32:22 PM »
Hi,

On the weekend I have written a new snippet to display the headlines of a specific news-section. anynews has a mode which might provide a similar functionality, but it didn't find any news-entries in my installation and the module is not maintained anymore (at least that's what I have found in the web).
My new snippet is basically a stripped-down version of the view.php of the news-module, and it displays the headline and publication date only, and visitors can click on the link for further reading.

Currently the snippet is very basic and not very flexible, but it suits my needs. if anyone finds it useful, the package is attached to this post.

Martin
How to use it in a template? There is an example?

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
Re: snippet: newslist
« Reply #2 on: January 25, 2016, 02:36:02 PM »
Hi,

ah, sorry, I should have mentioned it:
Code: [Select]
<?php   list_news(42); ?>

would show the headlines of the entries of section 42.

Martin

Offline Klimentiy

  • Posts: 12
Re: snippet: newslist
« Reply #3 on: January 25, 2016, 08:20:28 PM »

Warning: require_once(C:\OpenServer\domains\figtree\modules\newslist/languages/RU.php): failed to open stream: No such file or directory in C:\OpenServer\domains\figtree\modules\newslist\include.php on line 56

Fatal error: require_once(): Failed opening required 'C:\OpenServer\domains\figtree\modules\newslist/languages/RU.php' (include_path='.;c:/openserver/modules/php/PHP-5.5;c:/openserver/modules/php/PHP-5.5/PEAR/pear') in C:\OpenServer\domains\figtree\modules\newslist\include.php on line 56

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
update: snippet: newslist
« Reply #4 on: January 26, 2016, 02:32:30 PM »
Sorry, I ran into the same problem, but forgot to merge my fixes into the sources of the module package.
here is an update, which is hopefully complete.

Offline fab2000

  • Posts: 27
Re: snippet: newslist
« Reply #5 on: February 09, 2016, 04:19:42 PM »
I try the last version, but the page/s are white!!! If I delete it all again well.

Thanks

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
Re: snippet: newslist
« Reply #6 on: February 09, 2016, 06:23:54 PM »
which service pack (or which version of the news-module) do you use?
if you look at the html source of th "white page", is there anything at all? maybe html tags not properly nested?
If not, do you have access to the server logs which could give a hint?

I have the module running in wb 2.8.3 sp4 - but these days I have noticed problems with the news module itself when upgrading the test system. Some things must have changed in the news module, but I didn't have the time yet to debug that, yet. I'll also try the newslist in the upgraded test system to see if I run into a similar problem there.

Offline jacobi22

  • Posts: 5141
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
Re: snippet: newslist
« Reply #7 on: February 10, 2016, 12:53:10 AM »
I have the module running in wb 2.8.3 sp4 -

test in PHP 5.4.28 and PHP 5.6.3 with WB 2.8.3 SP5 and SP6 - works without Problems

My new snippet is basically a stripped-down version of the view.php of the news-module, and it displays the headline and publication date only, and visitors can click on the link for further reading.

the link doesnt work and i've a lot of brackets

Etwas ist nur unmöglich, wenn man glaubt, dass es das ist!

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
Re: snippet: newslist
« Reply #8 on: February 10, 2016, 10:46:26 AM »
the link doesnt work and i've a lot of brackets
that's exactly what I have seen for the News module as well, when I display the output using the section picker droplet. (I haven't tested  with the newslist sinippet yet).
The brackets are part of the formatting options of the news module shipped with latest service packs and unfortunately it has overwritten the settings during upgrade.
The fact that the links don't work is annoying and makes this snippet nearly useless. But since I see the same issue independent of the snippet it seems to be more related to the news module, but I'll have to investigate further what's the exact reason for this behavior. I just did not have the time yet.

@fab2000: Anyhow, you see a different behavior. It might be related to your  particular settings in the news module.  (or server logs might give a hint what's going wrong).
BTW, did you check that you are using the correct section id when calling news_list  (and make sure you did not confuse it with the page id of the page holding the news section)?

Offline fab2000

  • Posts: 27
Re: snippet: newslist
« Reply #9 on: February 10, 2016, 06:23:37 PM »
Thanks
I use CMS Version 2.8.3 SP5 Revision 1644 Admin version 1.6
PHP version: 5.6.17

I'm not a skilled programmer ...

TIA for your answer

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
Re: snippet: newslist
« Reply #10 on: February 10, 2016, 09:03:37 PM »
Hi, I had a closer look:
I have to update the snippet for sp5. I can't remove the brackets from the formatting of the news module, because obviously they have changed the semantics there. Where you previously had TITLE you now have [TITLE] etc.
The links work again for new posts, but not for the old ones which were written to the database with sp4 or older. That's probably true for any kind of access to the news entries (via sectionpicker droplet, direct call of the page, or using the newslist snippet).
So, I guess that I won't be able to fix that, but we'll see. I'm quite confident that I can fix the issue with the square brackets and perhaps the blank page results of an "old-style" query against a database filled with new entries.


Offline jacobi22

  • Posts: 5141
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
Re: snippet: newslist
« Reply #11 on: February 10, 2016, 10:55:18 PM »
only brainstorming...
#1 - why makePhExp() for this list?
#2 - is it not better to build a small template (htt or Twig)?

Twig is avaiable in Download-Area, only copy into a new include-folder Sensio/Twig
Etwas ist nur unmöglich, wenn man glaubt, dass es das ist!

Offline Martin Hecht

  • Betatester
  • **
  • Posts: 535
  • Gender: Male
    • meine Homepage
Re: snippet: newslist
« Reply #12 on: February 11, 2016, 08:08:36 AM »
Hi,

here is an updated version which should work for sp5 as well.
Most of my speculations were simply wrong. makePhExp actually was the clue. This function was used in the news module shipped with sp4 and earlier but it doesn't work anymore with sp5 and later, so I had to fix this.
There was also a mistake in the logic building the replacements -  the link was correctly displayed for users logged in, but it was removed when you weren't logged in.  This was simply a bug in the newslist snippet.
Twig/htt/templates: well, one could put more effort into this, but that snippet was just a quick hack which I need on a page I'm administrating. Maybe, when I find the time to do better, I can improve the snippet. There is room for improvement, sure.

@fab2000: does the new version work for you? and did you check the section number?
Martin


Offline fab2000

  • Posts: 27
Re: snippet: newslist
« Reply #13 on: February 11, 2016, 08:21:31 PM »
I'll try it
then I'll write results
thanks to all