Code Snippet: Display news items, anywhere

WebBird

There are language modules (DE.php, ...) in the languages subfolder of the module. Just open one of your choice and set the array key DATE_FORMAT to the format you wish to use.

There is no parameter.

Stefek

Could you please explain a little further?
Where to see and how to change in the snippet.

I hardcoded a change for myself in the inlcude.php of the snippet and produced a new PLACEHOLDER for the output. It works good for me, but I think there is a better way without changing the snippet files?

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

WebBird

See $LANG['DATE_FORMAT'] in the language module(s)

Stefek

Hello,

I wonder if there is no way to output just the date (w/o time) with this snippet.
Or did I overseen a parameter to call?

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

WebBird

I think the trick you needed to know is the usage of ob_start() etc. :-D

Franck707070



Franck707070

#395
Hi there,

I have a little problem.

I wanted to add a bit of code in order not to display the title "Nouvelles" and the corresponding DIV when there's no news to display. I tried both ways below without success. The echo doesn't display at all, even if there's some news to display and I don't understand why...  :?

First try:

<!-- Display News -->
<?php
if (function_exists('displayNewsItems')) {
    
$test displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
    if (
$test != "")
    {   
        echo 
'<div id="menunews" style="display:block;">';
        echo 
'<a href="http://prix-excellence.com/pages/nouvelles.php">Nouvelles</a>';
        
displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
        echo 
'</div>';
    }
}
?>


Second try:

<!-- Display News -->
<?php
if (function_exists('displayNewsItems')) {
    
$test displayNewsItems(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
    if (
$test != "")
    {    
?>

       <div id="menunews" style="display:block;">
       <a href="http://prix-excellence.com/pages/nouvelles.php">Nouvelles</a>
       <?php
        displayNewsItems
(0,31601$lang_id$strip_tags$allowed_tags$custom_placeholder$sort_by$sort_order$not_older_than);
        
?>

       </div>
       <?php
    
}
}
?>


advTHANKSance

WebBird

I get an error message with the second link.

You can create a custom layout by editing the "custom_output_display_mode_4.htt" file in the htt subfolder of AnyNews. All AnyNews placeholders are described there. You can also add your very own template file to the htt subfolder. See the help file for more information about this.

artifaction

I have a question i really hope someone can help me with.

If I add a image in the "short" section of a news item I can get that to show in anynews, but the problem is that it doesnt look good at all.

I want it to look like this.
http://www.magnuslofdahl.com/img_share/anynews_format.jpg

Is this possible? and how, where do I start.

This is the page I want to change, the news section at the bottom.
http://www.stylingutbildningen.se/

Please some advise would have been worth alot.

WebBird

I have addressed this issue above. Please make sure that you have the current version. If you do, please give an URL where to look at the problem.

mikejd

I have installed this snippet on a website and I am experiencing some odd behaviour which someone may be able to explain.

The length of the text quoted in the display can be set in the function call to a particular number of characters. I have noticed that this number appears to include any html tags in the short text entry eg if for instance a particular string is tagged as say h4 - <h4>xxxxxxxxxxx</h4> the count includes the <h4> and if the number, say 15, is less than the total number of characters, 20 in this case, the closing tag isn't included. This can result in a serious error in the html code for the page and cause major problems with the overall page display.

Has anyone else noticed this? Is there any solution apart from not using formating in the short text entry? In which case the FCK editor should not be available for that input box as it encourages editors to use it.

Any comments appreciated.

Mike

doc

#390
Hi,

the latest Version of Anynews v1.13 (AMASP only) includes an updated English Readme file. The examples in the README file make now use of the function parameter to make it more obvious what the different parameters are for :wink:

Doc

P.S.: Apart from the Readme file, no new functions were added

WebBird

Quote from: doc on October 07, 2009, 09:38:46 AM
Hi,

as Dietmar mentioned, try to add the <b> tag to the allowed tags.

But Dietmar meant that <b> is not allowed in the href attribute (by the HTML standard), apart from adding it to the list of allowed tags. ;)


doc

#387
Hi,

as Dietmar mentioned, try to add the <b> tag to the allowed tags.
In addition I would suggest to use the following function call, which makes it much more obvious, for what the various parameter are for.


<?php
displayNewsItems
(
  
$group_id = array(1516171819),
  
$max_news_items 5
  
$max_news_length 1,
  
$display_mode 2,
  
$lang_id 'NL',
  
$strip_tags true,
  
$allowed_tags '<p><a><img><b>',
  
$custom_placeholder false,
  
$sort_by 2
  
$sort_order 1
  
$not_older_than 0); 
?>



Also check the settings for max_news_length which is currently set to 1 and the setting for the language, which should be wrapped in quotes 'NL' instead of NL :-)

Doc

Luisehahne

Quote<li><a href="{LINK}">{TITLE}</a></li>

b tag is not allowed there

Dietmar
Note: Once the code has been generated, it is easy to debug. It's not a bug, it's a feature!

joep

Hello people.

I've got a problem with the LINK to the news page.

I've got this script:

displayNewsItems(array(15, 16, 17, 18, 19), 5, 1, 2, NL,
  true, '<p><a><img>', false,
  2, 1, 0);


This works fine!!

The only problem is when i click a menu item, it doesn't link to the specific news page, but the overview page.


<div class="anynews">
<ul>
<!-- BEGIN news_block -->
<li><a href="[b]{LINK}[/b]">{TITLE}</a></li>
<!-- END news_block -->
</ul>
</div> {LINK}


The link in this code does that..

Anyone knows how to fix this??

Thnq
Joep Muijres

erpe0812

Hi Webbird

the new code is working for me...........

Thanks.

erpe


tiesy

Hi WebBird,
thanks for your help. I´ve tested your code, but there is no difference. I´ll wait for the next version.


WebBird

The 8th param is wrong.
($custom_placeholder    false:= none (default), array('MY_VAR_1' => '%TAG%#', ... 'MY_VAR_N' => '#regex_N#' ...)

I think you confounded with #9, $sort_by.

This works fine for me:


if (function_exists('displayNewsItems')) {
   displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 5,
       $lang_id = 'DE',
       $strip_tags = false,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );
   //displayNewsItems(57, 87, 260, 5,'DE' ,'true' ,'<p><a><img>' , 1, 0);
}

tiesy

Hi WebBird,

that is the anynews-snippet in my code-section:

echo "<h4>Neueste Beitr&auml;ge</h4>";
if (function_exists('displayNewsItems')) {
   displayNewsItems(2, 2, 260, 5,'DE' ,'true' ,'<p><a><img>' , 1, 0);
}


and here is the html-output:

<h4>Neueste Beitr&auml;ge</h4><div class="anynews">

<h5>Demokratie, Verfassung, Interessenvermittlung</h5>

<p><p><img width="50" hspace="5" height="57" align="left" alt="" src="http://www.politik.uni-osnabrueck.de/cms/media/marx.jpg" />Was unter dem Begriff Demokratie zu verstehen ist, dar&uuml;ber gehen nicht nur im Alltagsverst&auml;ndnis die Meinungen auseinander. Auch in der Wissenschaft gibt es ganz unterschiedliche Vorstellungen. <a href="http://www.politik.uni-osnabrueck.de/cms/pages/de/forschung/politik-der-deutschen-vereinigung/kampf-um-die-finanzierung-der-deutschen-einheit.php">Die Begriffe numerische Demokratie,</a> deliberative Demokratie und Verhandlungsdemokratie bezeichnen <a href="http://www.politik.uni-osnabrueck.de/cms/pages/de/forschung/politik-der-deutschen-vereinigung/kampf-um-die-finanzierung-der-deutschen-einheit.php">prinzipiell unterschiedliche</a> Verfahren zur Herstellung und Legitimation verbindlicher kollektiver Entscheidungen.</p></p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/demokratie-verfassung-interessenvermittlung-7.php">weiterlesen</a></p>
<hr>
<h5>Im Osten nichts Neues </h5>
<p><p><a href="http://www.spiegel.de" target="_blank">Die Berichte der Bundesregierung zum Stand der Deutschen Einheit vermitteln eine ambivalente  Botschaft</a>.  Nur  wer  sie  in  Serie  liest,  erkennt  einen  seit  Jahren  anhaltenden Grundtenor. Er besagt, dass es, abgesehen von einer Vielzahl gefeierter Einzelprojekte, nichts  Neues  zu  berichten  gibt:  Stillstand  im  Osten  lautet  letztlich  das  Fazit.</p></p>

<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/im-osten-nichts-neues-6.php">weiterlesen</a></p>
<hr>
</div>


This works great, but if I reduce the length to 250 I get only the Headlines, no teaser-text:

The output with length 250:

<h4>Neueste Beitr&auml;ge</h4><div class="anynews">

<h5>Demokratie, Verfassung, Interessenvermittlung</h5>

<p>...</p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/demokratie-verfassung-interessenvermittlung-7.php">weiterlesen</a></p>
<hr>
<h5>Im Osten nichts Neues </h5>
<p>...</p>
<p><a href="http://www.politik.uni-osnabrueck.de/cms/pages/posts/im-osten-nichts-neues-6.php">weiterlesen</a></p>
<hr>
</div>

I have installed your actual version 1.12.




WebBird

Can you provide me a complete test case, please? (Post "Short Text" as HTML Code here for Copy&Paste.)

tiesy

#379
Hi WebBird,

thanks for the new version, but I can´t see a difference. It´s the same behavior as in 1.11:

The short-text is only shown correctly on frontpage, when the number of caracters are set high enough to show the hole short-text. If the short-text has more caracters than set in the code-secton, HTML-brackets are shown on frontpage.

Vielleicht nochmal auf deutsch, weil verständlicher: Ich sehe zu 1.11 keine Änderung. Die Kurztexte werden über das anynews-snippet nur dann korrekt dargestellt, wenn die Anzahl der Zeichen so hoch eingestellt wird, dass auf jeden Fall der gesamte Kurztext damit abgedeckt wird.  Irgendwie passiert der Fehler also beim Zählen der Zeichen und Abschneiden des Kurztextes.
Das Problem ist, dass man ja dem Anwender schlecht vorschreiben kann, bloß keine Formatierungen im Kurztext vorzunehmen.

WebBird

#378
I will have a look at it when I have some free time. (Not within the next weeks.)

Edit: Please take a look at version 1.12. Is this okay?

[gelöscht durch Administrator]