10931 Posts in 2614 Topics by 1810 members
|Go to End|
1 November 2011 at 4:57am Last edited: 1 November 2011 4:59am
Does anyone knows how or point me in the direction to show the last guestbook entry(using the simple guestbook module) in the sidebar?
Thanks in advance.
2 November 2011 at 9:06pm
do you have programming skills? Otherwise I'd have to implement that ;-)
If you do it yourself:
Create a new dataobject and select from table 'GuestbookEntry', either by date ('Created') or by MAX ID (latest should be the current guestbook entry).
3 November 2011 at 12:18am
I do have 'some' php programming skills, but mostly front-end.
Do you mean having something like:
$posts = DataObject::get('GuestbookEntry', '', 'Created', '');
I assume that the function has to be in Page.php to be available for all the pages and then having something in the Sidebar.ss like:
<% control guestPosts %>
<p>By $FirstName - $Created.Nice</p>
<% end_control %>
The thing I'm not sure of, is the query itself -- could you help me with that please?
Thanks a lot!
3 November 2011 at 12:54am
yes, that was the solution I'd suggest ;-)
Problematic is the relation of entries to comments if you want to show those, too.
A good resource for this issue is this
What you need is (sql):
ORDER BY Created DESC
put into a dataobject:
$objData = DataObject::get(
'Created', //sort by
That's also correct in your example - I'm not sure about the sort... I'm faintly remembering, one has to add "ORDER BY" or sth, even in the method call, but I can't test right now (and I mostly use raw SQL and covert results to dataObjectSets). Nevertheless you're also able to add the comments in the join clause.
Packed into your suggested method and calling it via frontend should do the trick. If you create an own extension to the page class in your /mysite directory (see the tutorials), you should be able to add this data to the sidebar on all pages.
3 November 2011 at 2:17am
I don't need to show the comments, no problem about it. I implemented the query as you suggested and simply by putting the function into Page.php and calling it in an include file called in the sidebar it works like a breeze!
One more thing. I have an issue with reCaptcha. When I try to enter a new guestbook entry from the website (not in the cms) I have this error:
Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\website\recaptcha\code\RecaptchaField.php on line 363
Is it because I'm running the website on my localhost? By the way I've got the reCaptcha keys and all that set in the _config file.
Thanks for you help!
3 November 2011 at 5:10am
the CURL error could have a few causes, most likely your local webserver or php-configuration. CURL is used to access remote server content (I think, the captcha images) and if that is blocked or CURL not installed/initialized in your local environment: error.
|Go to Top|