Forum OpenACS Q&A: General-Comments with Edit-This-Page?

Hi,

Has anyone successfully set up general-comments with ETP?  There is a
sample file in the tcl directory of the etp package but I've not had
luck getting it to work.  I'd appreciate any help...

Collapse
Posted by Neophytos Demetriou on
Add etp::get_gc_link to edit-this-page/templates/article-content.tcl Add to edit-this-page/templates/article-content.adp:

<if @comments@ not nil>
@comments@
<p>
@comments_link@
</if>
Modify get_gc_link as follows (inside a file under edit-this-page/tcl):

 ad_proc -public get_gc_link { } { } {
        upvar pa pa
        upvar comments comments
        upvar comments_link comments_link
        set item_id $pa(item_id)
        set object_name $pa(title)
        set comments ""
        set comments_link ""

        append comments_link [general_comments_create_link -link_text "Blah Blah Add a comment" -object_name $object_name $item_id [ad_conn url]]
        append comments [general_comments_get_comments -print_content_p 1 -print_attachments_p 1 $item_id ]



}
Collapse
Posted by Ivan Histand on
Neophytos,

Thanks for the code, I've applied it and it works now. The only change I made was in the adp page, the <if @comments@ not nil>  needed to be <if @comments_link@ not nil>  because until someone actually posted a comment then $comments was still nil, a catch-22 situation.

Thanks again!

Collapse
Posted by Neophytos Demetriou on
Ivan, you're right. In my code I have two separate if conditions -- I was just trying to save some keystrokes, especially &gt; :)
Collapse
Posted by Yves Goldberg on
I wasn't successful at applying the above code to add comments to ETP pages.

Anyone can confirm it still the way to go with 5.0 final?

Thanks.
Yves.

Collapse
Posted by Orzenil Silva Junior on
Hello Yves

I don't know if you are still interested about your question but I went into add comment link to edit-this-page - OACS 5.1 - and the code provided still works with minor changes.

1. Just put into /packages/edit-this-page/tcl/etp-gc-procs.tcl

namespace eval etp {

ad_proc -public get_gc_link { } {
  Called from rotisserie questions template to present      comment link
    taking out permission checking for now
    @author Pat Colgan mailto:pat@museatech.net
    @creation-date 4-17-01

} {
    upvar pa pa
    upvar comment_link comment_link
    set item_id $pa(item_id)
    set object_name [etp::get_name]
    set comment_link ""

    append comment_link "<center>[general_comments_create_link -object_name $object_name $item_id ]</center>"
    append comment_link "[general_comments_get_comments -print_content_p 1 $item_id ]"
    return "$comment_link"
  }
}

Important: watch this file in /acs-admin/apm

2. Put into your news-content.tcl

etp::get_page_attributes
etp::get_gc_link

3. Put into your news-content.adp

<if @comment_link@ not nil>
@comment_link;noquote@
</if>

/Orzenil

Collapse
Posted by Nima Mazloumi on
Orzenil,
why don't you add this as an parameter to ETP and commit your work to CVS?

Greetings,
Nima

Collapse
Posted by Lachlan Myers on
I presume the code should go in etp-gc?
Thanks
Collapse
Posted by Orzenil Silva Junior on
Lachlan,

It is a doubt for me :)

I'm really a newbie in OpenACS programming - maybe I am just a little competent administrator for dotLRN communities I help maintain here in Brazil. I'm a free software movement fan and a amateur programmer - just for fun not by profession (I'm a teacher).

Thats ok. I modify the code in etp-gc distributed in etp package once original one didnt work - so I put upvar into proc (as I learned from TCL/TK practical programming book) and other minor changes as I said. Still didnt work: requesting etp:get_gc_link from my modified etp (in /www/templates/news-content.tcl) I got an error.

So I change name from etp-gc to etp-gc-procs and put this file under "watch". Thats ok now. Cancel wath.

Could you teach me how it could work with code in etp-gc? I will appreciate your help. Thanx.

Nima, thanx for your guidelines to put comments as a parameter for etp. I'll go into this and try to make attachments with etp too.

\Orzenil

Collapse
Posted by Lachlan Myers on
Nope - you're correct.
If watching, it needs proc in the filename
Collapse
Posted by Ben Chan on
Has anyone else been getting this problem with Edit-This-Page 1.6?

invalid command name "etp::get_application_param"
    while executing
"etp::get_application_param index_template"
    invoked from within
"if {[empty_string_p $name] || $name == "index"} {
    set path "/[etp::get_application_param index_template]"
} elseif {[string match "etp*" $name]} {..."
    (file "/web/userful2/packages/edit-this-page/www/index.vuh" line 29)
    invoked from within
"source [ad_conn file]"
    (procedure "rp_handle_tcl_request" line 3)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
                $handler
            } ad_script_abort val {
                # do nothing
            }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
Collapse
Posted by Jade Rubick on
Can someone please post this as a patch to bug-tracker, or commit the code themselves?
Collapse
Posted by Orzenil Silva Junior on
Hi Jade,

I have this modifications as a patch but I did not add comments as a parameters as suggested by Nima. If you think that is ok I will send it to bug-tracker. Meanwhile I intend to add this parameter.

Collapse
Posted by Nima Mazloumi on
Hi all,
I was told that general comments allow file attachments. Is this correct?
Greetings,
Nima
Collapse
Posted by C. R. Oldham on
Yes it does, but I think last I looked you could upload a file, but when viewing the comment you could not download it again.  I might have been missing something simple.