Index: openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 1 Dec 2001 23:19:03 -0000 1.6 +++ openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 10 Dec 2001 23:56:24 -0000 1.7 @@ -32,7 +32,7 @@ ad_proc -public add_self_to_page { portal_id - community_id + instance_id } { Adds a news PE to the given page with the community_id. @@ -42,13 +42,25 @@ @author arjun@openforce.net @creation-date Sept 2001 } { - # Tell portal to add this element to the page - set element_id [portal::add_element $portal_id [my_name]] - - # The default param "community_id" must be configured - set key "community_id" - portal::set_element_param $element_id $key $community_id + # Add some smarts to only add one portlet for now when it's added multiple times (ben) + # Find out if bboard already exists + set element_id_list [portal::get_element_ids_by_ds $portal_id [my_name]] + if {[llength $element_id_list] == 0} { + # Tell portal to add this element to the page + set element_id [portal::add_element $portal_id [my_name]] + # There is already a value for the param which must be overwritten + portal::set_element_param $element_id community_id $instance_id + set package_id_list [list] + } else { + set element_id [lindex $element_id_list 0] + # There are existing values which should NOT be overwritten + portal::add_element_param_value \ + -element_id $element_id \ + -key community_id \ + -value $instance_id + } + return $element_id } @@ -80,31 +92,41 @@ from news_items_approved where publish_date < sysdate and (archive_date is null or archive_date > sysdate) - and package_id = $config(community_id) + and package_id = :instance_id order by publish_date desc, item_id desc" set data "" set rowcount 0 if { $config(shaded_p) == "f" } { + + # Should be a list already! XXX rename me! + set list_of_instance_ids $config(community_id) - db_foreach select_news_items $query { - append data "
  • $publish_date: $publish_title" - incr rowcount - } +# ad_return_complaint 1 "$list_of_instance_ids" - set template "" + foreach instance_id $list_of_instance_ids { + db_1row select_name \ + "select name + from site_nodes where node_id= (select parent_id from site_nodes where object_id=:instance_id)" + + append data "
    $name (more)" + db_foreach select_news_items $query { + append data "
  • $publish_date: $publish_title" + incr rowcount + } + + set template "" - if {!$rowcount} { - set template "No news items available

    more..." - } else { - append template "more..." - } + if {!$rowcount} { + set template "No news items available

    more..." + } + } } else { # shaded set template "" } - + set code [template::adp_compile -string $template]