Jump to content


NewsListing


181 replies to this topic

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


#21 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 21 December 2004 - 07:32 AM

hhmm... I see what you mean - but cant delete the <p> ?!
In stead I've stopped the p with a </p> right before the a-ref - but the output gets a little long..

here's the a part of the snippetcode - where it all is generated.

                
// strip the content 
         if(strlen($resource[$x]['content'])>$lentoshow) { 
            $rest = substr($resource[$x]['content'], 0, $lentoshow); 
            $rest .= "...<br /> </p> <a href='index.php?id=".$resource[$x]['id']."'>More on this subject></a>"; 
       }   else { 
            $rest = $resource[$x]['content']; 
          }
         $output .= "<fieldset><legend>".$resource[$x]['pagetitle']."</legend>".$rest."<br /><div style='text-align:right;'>Publiceret den ".strftime("%d-%m-%y %H:%M:%S", $resource[$x]['createdon'])."</div></fieldset>"; 
      }
   } 
} 

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 />";          
   } 
}

return $output;
  


#22 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 21 December 2004 - 08:18 AM

aha.... the <p> comes from the page with the content....

edited : Think I have to do so, if i want to use the RichText / Editor - and think I got to, because more users are supposed to post news - and they aren't familiar with any codes at all

#23 Guest_eko40_*

  • Guests

Posted 21 December 2004 - 08:35 AM

Espersen, where's your link to etomite?

#24 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 21 December 2004 - 08:41 AM

It's at the bottom of the page - at the right ;o)

Hopes it isn't too hard to see - off course I want to show who really has done all the hard work !

#25 Guest_Alex_*

  • Guests

Posted 27 December 2004 - 10:20 AM

You could use strip_tags($resource[$x]['content']) in the snippet to remove ALL html tags from the newslisting's content bit. It might look a little weird, but it WILL validate. Check the eto site itself, That's what I've done for the Announcement and Latest Support Question section.

#26 sottwell

    Etomite Forum Fan

  • Member
  • Pip
  • 60 posts

Posted 31 December 2004 - 12:12 PM

I am designing a multilanguage site, and all is working fine except for the news listing snippet.

In my main menu generation snippet, first I check the Session, if the lang is set there then use it. Then check GET, if the lang is set there use it and set the Session variable to that. If lang is still not set, go with a default and set the Session variable to the default. The only time the Session variable is not set is for the first entry into the site.

Th problem is that the Session is deleted when going off to read a news item. This resets the main menu to the default language.

I checked this by dumping the Session variables in my menu generation snippet. Clicking on the "read more" or "older news" links causes the Session to vanish; even an empty session would show an empty array with print_r($_SESSION)!

Can anyone help with this?

#27 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 31 December 2004 - 02:34 PM

sottwell, on Dec 31 2004, 08:12 AM, said:

I am designing a multilanguage site, and all is working fine except for the news listing snippet. 

In my main menu generation snippet, first I check the Session, if the lang is set there then use it.  Then check GET, if the lang is set there use it and set the Session variable to that.  If lang is still not set, go with a default and set the Session variable to the default.  The only time the Session variable is not set is for the first entry into the site.

Th problem is that the Session is deleted when going off to read a news item.  This resets the main menu to the default language. 

I checked this by dumping the Session variables in my menu generation snippet.  Clicking on the "read more" or "older news" links causes the Session to vanish; even an empty session would show an empty array with print_r($_SESSION)!

Can anyone help with this?
You might want to try storing the language variable as a $GLOBALS variable as when you manually set the $GLOBALS['your_var'] variable it will take precedence over $_SESSION, $_GET and $_POST variables... At least this is what I have found to be the case with my own testing... I've noticed several inconsistencies in passing $_SESSION variables... B)

#28 sottwell

    Etomite Forum Fan

  • Member
  • Pip
  • 60 posts

Posted 01 January 2005 - 01:59 PM

Well, I just added a line at the top of the snippet $lang = isset($_GET['lang'])? $_GET['lang'] : "en"; then add it to the generated links, <a href='[~".$resource[$x]['id']."~]&lang=$lang'>. Works great.

Everything is fine, the multilanguage scheme I worked up is working, the template I made looks great, after a few tweaks and hacks in the CSS it even looks good in IE/Win.

Now, however, I've got some pages that don't load the content, but only with IE/Win. Even IE/Mac works! Full news articles, and one other very simple page of links, load the template, the menus, and leave the content area blank. :angry:

[edit]
Turns out if I "view source" or refresh the page, the content suddenly shows up. What's with IE/Win? I use a Mac, so I don't know that much about it. Except that it's a peice of trash. :angry: :angry:

#29 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 01 January 2005 - 02:26 PM

Win IE is a sucker for sure. Usually when I have a disappearing element problem it revolves around a float or a width conflict (because the WinIE box model is all messed up). If you post a link to the page, we might be able to take a gander and see if there are any problems we've dealt with before.

#30 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 01 January 2005 - 04:29 PM

sottwell, on Jan 1 2005, 09:59 AM, said:

Well, I just added a line at the top of the snippet $lang = isset($_GET['lang'])? $_GET['lang'] : "en"; then add it to the generated links, <a href='[~".$resource[$x]['id']."~]&lang=$lang'>.  Works great.
Looks like you've stumbled across one of the minor quirks with PHP code written for Etomite snippets - the need to use $_GET['var'] to grab the results sent by a form... When I first looked at your partially posted snippet code I was unaware of the fact that you weren't using this method... What seems to create the confusion regarding this concept is the fact that you are not required to use $_GET for variables passed to snippets, yet the usage is required for retrieving form data passed back to the snippet, a method which is often not practiced when writing stand-alone PHP scripts... The scenario that I described in my previous post was related to circumstances where $_GET, $_POST, and $_SESSION variables aren't functioning as expected... It's nice when soultions are easier than we expect... B)

#31 sottwell

    Etomite Forum Fan

  • Member
  • Pip
  • 60 posts

Posted 01 January 2005 - 05:06 PM

I originally wasn't using GET values, I was thinking to set the lang in the user's session; that way I wouldn't have to find all the code for generating links and modify it to add the query string. But since sessions aren't too consistant, then I went back to using GET. I don't know if I have to get the variable from GET myself, but I'm in the habit of doing that anyway; ever since RegisterGlobals got turned off by default, and I figure it can't hurt. I prefer to know where my data is coming from.

I finally got fed up with IE/Win, and went back to a table-based layout for my template. Even then it managed to f&*#k it up and I had to hack at the css to make it work right. What a pain.

#32 miels

    Etomite Forum Newbie

  • Member
  • 39 posts

Posted 05 January 2005 - 08:39 AM

The problem I'm having probably has something to do with the reason why they pages generated don't validate:

In the page where the [[NewsListing]] tag is found and the short stories are being displayed, the snippet seems to just cut of the text at the given length. It doesn't check for any html tags to be open or not.

I ran into this problem quite soon. The text got cut of where a link (<a href) was still open. This messed up the result.

It might help if the script checked if at the place where the text is being cut of any tags are open, which are being closed later on in the document. This eliminates the need of listing all tags that should be closed. When the source text is correct every tag should get closed as is should.

Unfortunately I don't have a clue how to implement this... Anybody does? :unsure:

#33 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 05 January 2005 - 02:29 PM

miels, on Jan 5 2005, 04:39 AM, said:

The problem I'm having probably has something to do with the reason why they pages generated don't validate:

In the page where the [[NewsListing]] tag is found and the short stories are being displayed, the snippet seems to just cut of the text at the given length. It doesn't check for any html tags to be open or not.

I ran into this problem quite soon. The text got cut of where a link (<a href) was still open. This messed up the result.

It might help if the script checked if at the place where the text is being cut of any tags are open, which are being closed later on in the document. This eliminates the need of listing all tags that should be closed. When the source text is correct every tag should get closed as is should.

Unfortunately I don't have a clue how to implement this... Anybody does? :unsure:
The task of checking for open HTML tags, as well as CSS elements, would take some work to implement... That isn't to say that it couldn't be done, however... Without doing some in-depth research into this I'd venture to guess that it would take more code to do the tag checking than the [[NewsListing]] snippet itself... This has been a concern that I have had when working on my Blog snippets... B)

#34 jaredc

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,193 posts

Posted 05 January 2005 - 02:45 PM

And this is one reason I prefer to rely on the "description" field rather than a truncated portion of the full content. Description has no HTML in it and was created specifically to be a descriptor of the document. I figured that was a pretty good thing to have as a teaser, and has worked well in my case. You may have different needs, but it's something to consider.

If you are willing to step away from truncated body text and look at using the description instead, then you have more snippet options available for use.

#35 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,506 posts
  • Gender:Male

Posted 05 January 2005 - 03:03 PM

jaredc, on Jan 5 2005, 10:45 AM, said:

And this is one reason I prefer to rely on the "description" field rather than a truncated portion of the full content. Description has no HTML in it and was created specifically to be a descriptor of the document. I figured that was a pretty good thing to have as a teaser, and has worked well in my case. You may have different needs, but it's something to consider.

If you are willing to step away from truncated body text and look at using the description instead, then you have more snippet options available for use.
Good point, Jared... And it wouldn't be very hard at all to modify any of the existing NewsListing/Blog snippets to perform as you have described... I haven't put the "description" field to much use and should prbably entertain the idea of doing so for future snippet designs/mod's... B)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users