Code Snippet: Display news items, anywhere

doc

QuoteBTW: The snippet has vanished from the "official" code snippet page...
Thanks, forgot to activate the snippet - fixed.

Regards Christian

Katerchen

Okay, now it works. Thank you! BTW: The snippet has vanished from the "official" code snippet page...

doc

Hi,

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

$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

Katerchen

#224
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
$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.

doc

Hello,

just released Anynews v0.33 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:
  • added possibility to sort news by published_when column ($sort_by :=3)

Details can be found in the module help file.

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

Stefek

Quote from: Katerchen on January 06, 2009, 01:10:27 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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Katerchen

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?

albatros

Hi Christian,

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

Best regards

Uwe
أنا لست إرهابيا. ليس لدى أي ورشة عمل القنبلة في الطابق السفلي. ليس لدى أي مرض الجمرة الخبيثة أيضا. أريد شراء لا مادة الريسين. أنا سوف ابدأ السفر إلى الولايات المتحدة الأمريكية

doc

#219
Hello,

just released Anynews v0.32 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:

  • fixed bug with $max_news_length (setting was ignored from 0.30 onwards)
  • added placeholder {PUBLISHED_WHEN} which can be used in the templates files (/htt)
  • added possibility to define custom template output files by setting $display_mode (3..99); requires a file called "custom_output_display_mode_X.htt in the /htt folder)
  • increased max. value of $max_news_items from 10 to 999 (min:=1, max:=999, default:=10)

Details can be found in the module help file.

Regard Christian

chabar2000

Does anybody have the same problem: max_news_length does not work, short text is always shown completely.
<?php
if (function_exists('display_news_items')) { display_news_items(02101,   'News''Read more...''No news'); } ?>

Any hint? Thank you!
Karl

Katerchen

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!

doc

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

Katerchen

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?

doc

Hello,

just released Anynews v0.31 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:

  • possibility to style text output via template files located in anynews/htt/*.html
  • two new parameters to sort news by position or posted_when in decending or ascending order

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.

Regard Christian

doc

@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

erpe0812

Hi Doc,

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

rgds


erpe

Stefek

#211
Cool stuff, Doc.

Will test tomorrow.

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

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

doc

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

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:
QuoteNEWS 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]

erpe0812


Stefek

If the another site is hosted by the same provider...  :wink:
else ... I don't know.

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

erpe0812

QuoteDo 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

Stefek

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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

erpe0812

Hello

I did not get the publish date displayed at my anynews code-section:
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

doc

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. Just download the latest version and install it over the existing one via the WB backend.

Regards Christian

spida

Hi there,

I don't get the display working.
If I use this code according to the readme
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]