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

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #425 on: January 22, 2010, 01:08:39 PM »
Hi,

the Anynews function call shown in the info section of AMASP seems to be corrupt. Think it has to do with the allowed tags <a>. Think a small bug in the edit dialoge of the module used.
http://www.websitebakers.com/pages/code-snippets/listings/anynews.php

Maybe the missing $ can be added to the README files with the next update.

Regards Doc

erpe0812

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #426 on: January 22, 2010, 01:40:20 PM »
Yes, I noticed it yesterday too.
Hope that Aldus will correct this soon.

Thanks for posting.

rgds

erpe

erpe0812

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #427 on: January 22, 2010, 04:03:53 PM »
@all who are interested in this:
https://forum.WebsiteBaker.org/index.php/topic,409.msg110386.html#msg110386

It was a bug in xfast_Template_2 and had nothing to do with anynews.........tho ugh it seems to have on the first impression.

Thanks to Webbird and Aldus for quick help.

rgds

erpe

aldus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #428 on: January 25, 2010, 10:10:38 AM »
Hm ...
I've update the modul "informati0n" at AMASP to leave html-source inside a
pre tag uninterpreted, e.g.
Code: [Select]
<pre class="code">
&#x3c;ul id="myGallery" class="image-overlay">
&#x3c;li>
&#x3c;a href="http://www.domain.tld">
      &#x3c;img alt="Image 1" src="yourimages/Image1.jpg"/>
      &#x3c;div class="caption">
        &#x3c;h3>My Image&#x3c;/h3>
        &#x3c;p>click for more info&#x3c;/p>
      &#x3c;/div>
    &#x3c;/a>
  &#x3c;/li>
&#x3c;/ul>
</pre>

by replacing the opening braked < to his hex-entity &#x3c; .
So you can (now) display source inside the description/information fields
like shown at
http://www.websitebakers.com/pages/code-snippets/various/image-overlay.php

Also replaced the $ char to avoid PHP-Conflicts in examples, like "var $xyz is not defined" ...

Regards
Aldus

kleo

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #429 on: January 25, 2010, 07:42:48 PM »
I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

More thanks!


Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #430 on: January 27, 2010, 09:42:34 AM »
I've been asking about possibility to view the posts in "most commented" order:

https://forum.WebsiteBaker.org/index.php/topic,16548.0.html

I quess this is possible with Anynews, by modifying include.php. My coding skills are limited, so could somebody give me a hint?

Code: [Select]
sort_by...    5:= number of comments

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #431 on: January 27, 2010, 10:35:43 AM »
Hmmm... This requires a more complex SQL query, as the comments are stored in another table. You will have to modify the query (lines 127ff), or add another one especially for the comments count.

Are there any other ones interested in this feature?

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #432 on: January 27, 2010, 12:20:46 PM »
Please try the include.php attached. Be sure to make a backup copy of the original include.php before trying this one.

Edit: Removed attachment. New version available at AMASP. http://www.websitebakers.com/pages/code-snippets/listings/anynews.php
« Last Edit: January 29, 2010, 10:49:01 AM by WebBird »

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #433 on: January 27, 2010, 08:34:13 PM »
Seems to work. It would be good to display number of comments after the date in news list.

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #434 on: January 28, 2010, 10:54:21 AM »
Seems to work. It would be good to display number of comments after the date in news list.

I thought you would suggest this. Try COMMENTS markup. ;) (Custom Template)

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #435 on: January 28, 2010, 01:36:10 PM »
Just can't understand how to add number of comments to custom templates  :oops:

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #436 on: January 28, 2010, 01:52:26 PM »
Just add {COMMENTS} to the template you use at the position you wish.

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #437 on: January 28, 2010, 02:21:12 PM »
Not working. Do I need to add some custom placeholder also?

I tried adding
Code: [Select]
<tt>COMMENTS: </tt>{COMMENTS}<br /> in custom_output_displ ay_mode_4.htt

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #438 on: January 28, 2010, 02:54:35 PM »
Do you USE that template? (Param $display_mode in displayNewsItems call.)

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #439 on: January 28, 2010, 03:24:55 PM »
Maybe this helps...

If you do not set $display_mode, the default is 'detailed output'. The template file for 'detailed output' is htt/detailed_output.htt.

Here's the content of that file:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>

<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>

Just add the markup {COMMENTS} to that file. Example:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>
Number of comments: {COMMENTS}<br />
<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #440 on: January 28, 2010, 06:05:10 PM »
Tried that, but it is not displaying the number. Only "Number of comments: " and then blank

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #441 on: January 28, 2010, 06:24:07 PM »
Hm. Works for me. :?

Just saw that the text is outside the loop. Try this:

Code: [Select]
<div class="anynews">
<h2>{TXT_HEADER}</h2>
<!-- BEGIN news_block -->
<p><strong>{TITLE} {POSTED_WHEN}</strong></p>
Number of comments: {COMMENTS}<br />
{CONTENT_SHORT}
<!-- BEGIN readmore_link_block -->
<p><a href="{LINK}">{TXT_READMORE}</a></p>
<!-- END readmore_link_block -->
<hr />
<!-- END news_block -->
</div>

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #442 on: January 28, 2010, 07:48:36 PM »
No help. I think that variable {COMMENTS} is not set anywhere. Do I need some custom placeholder? Or does it need to be set in include.php. Or am I totally lost here?

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #443 on: January 29, 2010, 10:47:46 AM »
It is already set in the new include.php. But maybe I did not upload the last version. :?

Please download the new version 1.15 at AMASP and try it again.

http://www.websitebakers.com/media/amasp_uploads/anynews_v1.15.zip

Edit: Checked it out, it was missing in the include.php I provided for testing. I'm sorry. :|
« Last Edit: January 29, 2010, 10:49:31 AM by WebBird »

Offline Turskis

  • Posts: 50
Re: Code Snippet: Display news items, anywhere
« Reply #444 on: January 29, 2010, 12:02:08 PM »
Now it's working. Thanks, this was a very important feature for me!

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #445 on: January 29, 2010, 01:26:32 PM »
@Webbird: Would be nice if you could also maintain/update the README file with new releases. The latest implemented options seems to be missing. Also the README on AMASP and Add-ons point to an outdated version.

Regards Doc

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #446 on: January 29, 2010, 02:48:50 PM »
Yepp. Will write that on my Todo list. But I need help with the NL readme. :roll:

Offline seagull

  • Posts: 79
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #447 on: January 31, 2010, 11:20:56 AM »
Maybe i overlooked it, but when i use displayanynews with displaymode=2(only the newstitle as link) and having newsitems with only shorttext the resulting page displays the longtext wich is empty, so only the header and the footer are displayed.
Am i doing something wrong or is this the way the snippet should work?(only with long text)

@webbird, i would like to help you with the Dutch translation.

Jan

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #448 on: January 31, 2010, 03:16:46 PM »
Great, Jan, thank you! Just take the help_en.html to see what's new there and missing in help_nl.html.

I'll take a look at displaymode 2 tomorrow. Promise. :-D

Harry P.

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #449 on: January 31, 2010, 07:07:59 PM »
Hello All,

when I use the AnyNews call...

Code: [Select]
if (function_exists('displayNewsItems')) {
   displayNewsItems(
       $group_id = 2,
       $max_news_items = 10,
       $max_news_length = -1,
       $display_mode = 1,
       $lang_id = 'auto',
       $strip_tags = true,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );
}

... on a standalone CODE page, News teasers display fine within my template.

But when I pack the same into a droplet, say "Anynews", and place it on a WYSIWYG page with [Anynews]], the News teasers appear outside (above) my WB template.

Any idea what I'm missing? I walked through this whole thread but couldn't find a clue...  :?

 

postern-length