Page 1 of 1

{News} Add/View comments link

Posted: Sun May 08, 2011 6:43 pm
by samj
Hi
I have been pulling my hair out over these issues.
In my site I have a News-Summary with the News-Category-Menu on top; from here the user can either click to Category-Browsing and then to the Detail-Page or click to the Detail-Page directly from the Summary-Page. So far so good.

There are several cosmetic refinements I would like to see:
First off, in the Summary-Page and/or the Category-Page (if easily possible) and definitely in the Detail-Page I would like to have a "View Comments" button/link which brings the user to a Detail-Page containing the news post in detail with the corresponding comments below. --> The user, either reading the News-Summary or News-Category or News-Detail can decide whether to see the News-Detail with comments at the click of this button, instead of the default News-Detail only.

?: Two solutions come to mind. One could create a second Detail-Page which renders the News-Detail via default module behavior and Comments by hard-coding {CGFeedback}. This "commented" page is basically a copy of the original "basic" Detail-Page with additional code to display the comments.

Or, there might be a "dynamic" approach to render the additional comments below the "News-Post-Detail" on the same page, if so requested, without calling another complete page from the web. Although in this case, some data could be found in the browser's cache.
Or, there might be a built in functionality similar to what I am looking for unknown to me. etc...

[Note: I would like to keep it super simple and with as little javascript as possible]

Second, it might be useful to have a similar functionality with an "Add Comment" button. When the reader lands on the Detail-Page he/she finds the basic "News-Post-Detail" and two buttons below, the above mentioned "View Comments" and "Add Comment."

I have very limited understanding on how exactly everything interconnects; I can't even begin to imagine how I can put this together from a code perspective. For instance, how would the 2nd Detail -Page, the one with the comments know which news-detail to copy which comments to render, etc. , since the 1st Detail-Page was the result of a dynamically created link from within the Summary-Page? (pass through vars)
Might it even be better to plug in another module into the "News"- module and use part of it's functionality?

thanks, samj

Using newest version of everything; Xampp, vista home dev.

Re: {News} Add/View comments link

Posted: Sun May 08, 2011 7:07 pm
by uniqu3
samj,

to get comments to work with News you only need to add CGFeedback to your News Detail Template.

Something like:
{CGFeedback key1="News" key2=$entry->id action="summary"}

For more info read CGFeedBack Help.

Re: {News} Add/View comments link

Posted: Sun May 08, 2011 9:41 pm
by samj
thanks uniqu3, that was quick

The Comments are working fine. What I would like to accomplish is to have 2 links in the News-Detail-Page, below the News-Detail-Post, saying "add comment" and "view comments" which after clicking will ADD the chosen content below the buttons/links on the same page, namely the News-Detail-Page.
Basically, I would like for the viewer who sees the News-Detail-Page the first time, see the News-Detail (default, as is) plus the two links/buttons, only. Only, after clicking one of the two buttons should the additional info be visible.
I would also like to extend the functionality, of the "view comments"-button, if so easily possible at the same time, by placing it into the News-Summary-Page as well, one with each News-Post to allow the reader to directly click to the News-Detail-Page (coming from the Summary-Page) with the comments already displayed below the News-Detail-Post, but without the "Add-Comment-Field."
In my case, visible to the reader is only one page: News-Detail-Page, which by default displays the detailed news post only, and only upon request additional info.
The "View-Comments"-button/link of each News-Post, regardless of which page it is placed on, always leads to the same News-Detail-Page.

hope to have expressed myself more clearly, thanks

Re: {News} Add/View comments link

Posted: Mon May 09, 2011 8:32 am
by uniqu3
Oh ok i understand :)
If you are using jQuery framework you could easily do this with jquery toggle function.

You would need to wrap your CGFeedback "form" part and "comments" part in two div's with an id.
Before these two div'S there would be buttons saying "view comments" and "write commetns" with an id.

And you would controll these with toggle function.

Code: Select all

$('#your-button-id').click(function () {
$('#id-for-form-wrapping-div').toggle("slow");
});
You can read about toggle here http://api.jquery.com/toggle/