Jump to content


NewsListing


181 replies to this topic

#1 Guest_Alex_*

  • Guests

Posted 12 September 2004 - 12:45 PM

I have added a new snippet to the Snippet Library!

Snippet name: NewsListing
Author: Alex
Version: 1.0 (Final)
More info: View this snippet
Description:
Default snippet which shows excerpts from a selectable number of documents in a specified folder.

Please feel free to comment on this snippet, suggest improvements, or simply praise my work! ;)

[This is an automatically created message]

#2 kartav

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 16 September 2004 - 05:31 PM

Alex,
would you be so kind to add in your snippet support of Document Content Variables (http://www.etomite.com/index.php?showtopic=809&st=15), such as content_extra and plain_text?
Thanks in advance.

#3 luislacerda

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 16 September 2004 - 05:48 PM

Alex
I fiddled with the original snippet that comes with the Etomite package so that in the end I had to go to the snippet repository to collect a fresh (and working) one.

However in my installation the link that is under the More on this story always returns an html extension.

It reads like this
$rest .= "...<br />    <a href='".$resource[$x]['id'].".html'>More on this story ></a>";

which I had to change to

$rest .= "...<br />    <a href='index.php?id=".$resource[$x]['id']."'>More on this story ></a>";

to make it work in my intranet, which it does now.

Am I reporting some error with your code?
Cheers
Luis

#4 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 16 September 2004 - 06:24 PM

luislacerda, on Sep 16 2004, 01:48 PM, said:

Am I reporting some error with your code?Cheers
Luis
This is most likely happening because you aren't running Friendly URL's... :eto: Alex's code is correct for anyone running Friendly URL's, while your code is correct for anyone not running Friendly URL's... B)

#5 VTX

    Etomite Forum Newbie

  • Member
  • 17 posts

Posted 01 November 2004 - 09:17 AM

Hi,

I added a line of code, so that in the 'short news' the images are cut out. This is very handy if you have just a small table where you want the news to be in, so the layout doesnt get f##cked up when there are images used in the news. When someone clicks on 'Read more' then the images are displayed as normal.

Before:
 // strip the content 

Add:
 // Disable images in short news
         $resource[$x]['content'] = preg_replace('/<img (.*?)"[a-z0-9.:\/\/]+"(.*?)>/i',"",$resource[$x]['content']);


#6 Mr. Tech

    Etomite Forum Fan

  • Member
  • Pip
  • 65 posts

Posted 17 November 2004 - 09:04 PM

I needed the ability to automatically hide old 'news' items but the snippet wasn't coded that way. Having found a solution to my problem, I share the following:

Find this line -
$resource = $etomite->getAllChildren
Change it to -
$resource = $etomite->getActiveChildren
Now you can go back to your news items and set an un-publish date for the document.

#7 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 08 December 2004 - 06:54 PM

gbentley, on Dec 8 2004, 01:43 PM, said:

(copied from another thread)
Slightly different but I want to do the following :-

I have $nrblogs = 5;

So 5 short posts fit within one page without pushing the bottom of the page lower that the bottom of my RH menu.

OK so on the sixth article post what happens ?

I get ;

<b>More Like This<b>
Link to Next Post >>

I have reduced the first output to not display "More like this"

ie $output .= "";

Now I need to modify the following so that .....

for ($x = $nrblogs; $x < $limit; $x++) {
$output .= "> <a href='[~".$resource[$x]['id']."~]'>".$resource[$x]['pagetitle']."</a><br />";

I get ;

Link to Next Set of 5 Posts>>

A bit like 'Next Page' - but how ?

I still dont really understand the parent / child aspect of the Newslistings smile.gif

Any help or enlightenment welcomed (OK, I am a thicko !)
Clarification...
So what it sounds to me like you want is paging for your news. You don't want the "older news" to show up at all, but rather a LINK to the older news. Is that right?

If that is the case, you could code a link to a page that serves as an index for news (or whatever it is you're listing). So go from this:

if($limit>$nrblogs) { 
   $output .= "<br /><br /><b>Older news</b><br />"; 
   for ($x = $nrblogs; $x < $limit; $x++) { 
      $output .= "> <a href='[~".$resource[$x]['id']."~]'>".$resource[$x]['pagetitle']."</a><br />";          
   } 
}
To this:

if($limit>$nrblogs) { 
   $output .= "<br /><br /><b><a href='[~N~]' title='News Index'>News Index</a></b><br />";
}
Where "N" is the page id number of your index page. Of course this presumes you have a news index page. But unless I missed something, this snippet does not provide paging functions on its own. But since Alex hates writing paging scripts - I don't think I missed it.

You might take a look at the various uses of the ListIndexer snippet.

#8 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 08 December 2004 - 07:32 PM

Many thanks for the reply jaredc - however what happens is that I get the link

News Index

But when I click it - I get the same set of news / posts / artcicles / pages or whatever one calls them.

So, it works to a point ie it does show the news index but only the latest items - not the previous / older items ?

If you have any further ideas it would be great to get this working :)

(I have seen this done on loads of sites and assume its what would haeppen by deault !)

#9 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 08 December 2004 - 08:09 PM

gbentley, on Dec 8 2004, 02:32 PM, said:

So, it works to a point ie it does show the news index but only the latest items - not the previous / older items ?
What snippet are you using on your index page?
What is the URL so we can look at it?

You won't be able to use the NewsListing snippet as the index page snippet. It just won't pull the whole batch of stories. You need modify it to get older ones, or use ListIndexer. One note- ListIndexer uses page descriptions, NOT the first XXX number of characters from the story.

#10 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 09 December 2004 - 09:08 AM

Hi Jaredc

To describe better I have an item on my menu called Network Admin

I made this a folder. I then created documents under that folder (unpublished) but gave them the parent ID.

I then just put into the Network Admin 'Folder' the following ;

[[NewsListing?newsid=26]] where 26 IS the ID of Network Admin folder

Now when I click on Network Admin on the Menu all the documents with 26 as the parent appear.

I have set the number of blogs to be 6 and want a link to the next 6 at the bottom of each page.

You gave me this ammendment to the Newslisting script;

if($limit>$nrblogs) {
$output .= "<a href='[~N~]' title='News Index'>Next>></a>";
}

But it only shows the most recent of the ID26 bloggs

I was thinking about this and decided to try the following ;

I created another folder called Network Admin2 (ID36) and published some documents under it.

Now I would like to create a snippet based on yours above so I can pass
the variable N to it.

Something like [[NextBlogg?blogid=36]] and at the bottom of my 'folder' pages
display a next button.

Well I think you get my drift ?

Is this very ugly or is there a better way to achieve clicking next and going to the next set of older blogs ?

#11 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 09 December 2004 - 12:54 PM

I think I see your thinking. Basically you want a setup like:

+ Network Admin (as an index page)
  |-- Article 1
  |-- Article 2
  |-- Article N

I wouldn't use the NewsListing snippet for this. I would use ListIndexer. The ListIndexer snippet will page the results like you want. Providing the first 5 (or 10 or whatever you specify) on a page, then links to next pages. You would toss this on your Network Admin page in the content area, and it would take care of the rest.

Depending on how you feel about the description field, this could be the only drawback to this solution. ListIndexer uses the description field text rather than the first N characters. There are good reasons for this, but that's the way it is. Or,you "could" do it the way you describe, by putting 5 articles in a subfolder:

+ Network Admin (as an index page)
  +-- News Folder 1
      |-- Article 1
      ...
      |-- Article N
  +-- News Folder 2
      |-- Article 1
      ...
      |-- Article N

But then you're not capitalizing on the strength of the database and you'd be increasing your maintenance efforts.

#12 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 09 December 2004 - 03:21 PM

J, added snippet and inserted [[ListIndexer?LIn_link=26]] into the content area.

Now I just get ;

Most recent
Index

I am in a rush and prolly havent read the instructions properly but I am not sure if this is going to do what I want. I was hoping to replicate "Add Story" in PostNuke where you just add a storry and it get publised and pushes the rest of the stories down one. Does this just lists the stories or does it actuyally display them ?? Confused . . .

#13 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 09 December 2004 - 03:39 PM

gbentley, on Dec 9 2004, 10:21 AM, said:

I was hoping to replicate "Add Story" in PostNuke
This is not a blog snippet. Purely indexing. If you want to be able to add stuff via the page, you might want to look at Rad's MySimpleBlog, which may suite your needs.

#14 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 09 December 2004 - 05:30 PM

J, when you say indexing do you mean it will create a clickbale list of the artciles ? If this is the case then yes, Simple Blogg might be better however this is driving me nuts now becasue with the SimpleBlogg script I get ;

No blog entries found.

When I know for a fact there are 6 articles all under that folder ?

Any ideas ?

Just in case I never said it before - thanks for all your help :)

#15 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 09 December 2004 - 06:10 PM

Well, you'll have to wait for Rad (Rad14701) to troubleshoot that one for you. I'm not familiar with it except that I know his is a blog and mine is not. But hang in there. You'll get it. :D

#16 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 11 December 2004 - 10:12 AM

Thanks to everyone who has replied and helped me but there is just one thing I need to get working in Etomite and, rightly or wrongly, its the main way I envisaged using it.

I think some people have referred to it as 'paging'

Anyway, what I would like to is to have a page of short descriptions which contain links in news style boxes and at the bottom of that page have a single clickable link to the next set of descriptions / posts /articles or what ever you want to call them.

I have had a look at NewsListing and I like the way it formats the boxes with the title etc and I can specify how many I want on a page - but the one thing I need it to do eludes me because I am not a coder and no little about PHP or JS or CSS.

I can however follow instructions carefully and think *some* things through for myself. I know what I want and have looked long and hard at the examples in the existing scripts like NewsListing but cant quite figure out how to achieve this.

Jaredc and Rad have kindly helped out but I feel I am pestering them with this.

So, I was wondering if anyone out there has this type of scenario already figured out / working who would like to share their snippet with me ?

I guess it woudl need some kind of variable to hold the total number of items with their ID's, then to display N number of them and to generate addditional 'pages' with links. This sounds quite complicated from a non programmer viewpoint and I have no problem with using a workaround that comes close.

Any advice / ideas appreciated !

#17 gbentley

    Etomite Forum Fan

  • Member
  • Pip
  • 53 posts

Posted 11 December 2004 - 10:48 AM

I have thought about this and come up with my own workaround which really just involves nested subfolders and additional use of the NewsListing.

The only thing I need to change in NewsListing is that it shows the SubFolders of the folder it is in. How can I stop it doing this and to only show Documents ?

Thanks !

Edt: AND show a clickable link to the next Subfolder at the bottom of the N number of blogs ?

Just been reading the docs on data retrieval and noted the following :

mixed $etomite->getAllChildren(int $id, string $sortField, string $sortDir[, string $fields]);

This function is the same as the previous function, except all documents are returned, be they published/ deleted or not. Returns FALSE on failure.

and this on document variables ;

isfolder : Integer; true (1) if the document is a folder and false (0) if it is not.

looking at other examples I can see that adding isfolder to this line in NewsListing
will get me a 0 or 1, then I have filter out all but docs . . .

$resource = $etomite->getAllChildren($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, content, createdon, createdby, isfolder');

Now my head hurts . . a little help anyone ?

#18 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 20 December 2004 - 10:18 PM

I'm having trouble to validate the pages with the Snippet "NewsListing"
I have now spent at least 4 hours to find the error - and my head starts soon spinning.. :blink:

I've got some great help in here to correct some other snippets so they can validate 100% to the W3C-standards. :D

The W3C-link to see my errors

#19 yomemiconmigo

    Etomite Forum Fan

  • Member
  • Pip
  • 68 posts

Posted 20 December 2004 - 10:43 PM

espersen, on Dec 20 2004, 11:18 PM, said:

I'm having trouble to validate the pages with the Snippet "NewsListing" 
I have now spent at least 4 hours to find the error - and my head starts soon spinning.. :blink:
That's exactly why I chose ListIndexer instead. It does validate. The only difference is that ListIndexer doesn't show an excerpt of the news item, just the description you write when you create the document.
here's the link to the snippet library. I suggest you should try it and see if that's what you need http://www.etomite.com/browsesnippets.html...&lst_category=0

#20 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 20 December 2004 - 11:04 PM

espersen, on Dec 20 2004, 06:18 PM, said:

I'm having trouble to validate the pages with the Snippet "NewsListing" 
I have now spent at least 4 hours to find the error - and my head starts soon spinning.. :blink:

I've got some great help in here to correct some other snippets so they can validate 100% to the W3C-standards.  :D

The W3C-link to see my errors
Check out the section of code listed below... It doesn't have a closing </p>... This is only an exerpt of you validation codes line 39... I have added code formatting to make it more readable for trouble-shooting purposes only... See if correcting that solves your problem... B)

Quote

<fieldset>
  <legend>
    Ændrede flyttegebyrer for pensionsordninger
  </legend>
  <p>En række pensionsselskaber har netop sænket deres flyttegebyrer for de individuelle pensionsordninger, hvormed pensionsopsparerne ikke længere er stavnsbundet pga. de til tider meget store flytteomkostninger...<br />
  <a href='index.php?id=43'>More on this subject></a><br />
  <div style='text-align:right;'>
    Publiceret den 20-12-04 10:19:17
  </div>
</fieldset>






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users