I am having problems with the NewsListing snippet. I suspect there is a simple explaination, but I'm going nuts trying to figure it out.
I'm trying to test it out using the News directory and files that comes with Etomite.
I edited the line:
$resourceparent = isset($newsid) ? $newsid : $etomite->documentIdentifier;
to read:
$resourceparent = isset($newsid) ? $newsid : $etomite->News;
When I try to evoke the NewsListing snippet in a page I get the following error message:
« Etomite Parse Error »
Etomite encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed »
SQL: SELECT id, pagetitle, description, content, createdon, createdby FROM `zandar_politics`.etomite_site_content WHERE `zandar_politics`.etomite_site_content.parent= ORDER BY createdon DESC;
[Copy SQL to ClipBoard]
Parser timing
MySQL: 0.0039 s s (2 Requests)
PHP: 0.0209 s s
Total: 0.0248 s s
Since I am using the Etomite default News directory, and it's contents, this should work.
What am I doing wrong?
Thanks
Gary
Need help with NewsListing snippet
Started by The Bearded One, Nov 04 2004 05:57 PM
2 replies to this topic
#1
Posted 04 November 2004 - 05:57 PM
#2
Posted 04 November 2004 - 06:34 PM
$etomite->News is not a valid object reference. So that won't work. Perhaps a breakdown of what's going on would be beneficial:
This assigns the variable $resourceparent a value. The $resourceparent should be the id of the folder you want to get your news from.
isset($newsid)
To get that value, it tests to see if a snippet call variable named "newsid" was made.
? $newsid
If the snippet variable WAS set, that value is assigned to $resourceparent.
:$etomite->documentIdentifer;
If there was no snippet call variable, then then this value, ($etomite->documentIdentifier) is assigned to $resourceparent. $etomite->documentIdentifier simply uses the Etomite API to get the current pages id. It relies on the Etomite API $etomite object. That object has certain properties, which are coded into the Etomite core, and unless you have a good reason, don't need to change.
So, to solve your problem, the easiest way is to make the snippet call include the folder id of the folder you want your news to come from:
[[NewsListing?newsid=N]] Where N is the id number of the news folder.
A second method would be to replace the above line with:
[[NewsListing]]
This is NOT recommended however, as it makes the snippet locked into only using that ONE folder. Many folks want to have a variety of news folders, and having a NewsListing snippet that can be used for many is very efficient.
So then you could have snippet calls such as:
[[NewsListing?newsid=5]] for general news
[[NewsListing?newsid=17]] for sports news
[[NewsListing?newsid=22]] for comics
*Of course all these id numbers will vary based on your setup and are only examples.
Anyway, that's long winded but I hope it helps you see what the snippet is doing. You'll be much better equiped to use it well when you see how it works.
<note to="alex">
Maybe you should include how to make the snippet call in the Snippet Library author notes to clarify this. Seems like this question is coming up a lot. There was another one just today.
</note>
$resourceparent = isset($newsid) ? $newsid : $etomite->documentIdentifier;$resourceparent =
This assigns the variable $resourceparent a value. The $resourceparent should be the id of the folder you want to get your news from.
isset($newsid)
To get that value, it tests to see if a snippet call variable named "newsid" was made.
? $newsid
If the snippet variable WAS set, that value is assigned to $resourceparent.
:$etomite->documentIdentifer;
If there was no snippet call variable, then then this value, ($etomite->documentIdentifier) is assigned to $resourceparent. $etomite->documentIdentifier simply uses the Etomite API to get the current pages id. It relies on the Etomite API $etomite object. That object has certain properties, which are coded into the Etomite core, and unless you have a good reason, don't need to change.
So, to solve your problem, the easiest way is to make the snippet call include the folder id of the folder you want your news to come from:
[[NewsListing?newsid=N]] Where N is the id number of the news folder.
A second method would be to replace the above line with:
$resourceparent = N;Again, N would be the folder id of the news folder. The snippet could then simple be called with:
[[NewsListing]]
This is NOT recommended however, as it makes the snippet locked into only using that ONE folder. Many folks want to have a variety of news folders, and having a NewsListing snippet that can be used for many is very efficient.
So then you could have snippet calls such as:
[[NewsListing?newsid=5]] for general news
[[NewsListing?newsid=17]] for sports news
[[NewsListing?newsid=22]] for comics
*Of course all these id numbers will vary based on your setup and are only examples.
Anyway, that's long winded but I hope it helps you see what the snippet is doing. You'll be much better equiped to use it well when you see how it works.
<note to="alex">
Maybe you should include how to make the snippet call in the Snippet Library author notes to clarify this. Seems like this question is coming up a lot. There was another one just today.
</note>
#3
Posted 04 November 2004 - 07:42 PM
Jared,
That did the trick!
Thanks for the help.
Gary
That did the trick!
Thanks for the help.
Gary
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











