Forum OpenACS Q&A: Try setting up a portal table

Posted by Jowell Sabino on
I got to set up some portal tables, but I didn't load the education module (3.2.4 default). I commented out all the "inserts" towards the end of portals.sql.  The result is that if you try to administer portals, you won't have any sample portal table code to play with.  Fine by me, because they won't work anyways without the education module loaded.

    I think /portals/index.tcl only looks for portals with content.  Try going to /portals/admin and click on the "create new table" link.  Put anything on the "Table name" and the "HTML/ADP", type preview and then click on create.  Put this table in your test portal and check /portals again to see if your test portal comes up.

    In priciple, you can put any valid HTML or ADP code in "HTML/ADP" space. You just have to assume that 1)    you already have a valid database handle ($db), and 2) your HTML or ADP output will be put inside a table (see /docs/portals). This adp fragment will put the list of active polls in a portal table (sorry for the messy formatting.  Making this post html further messes up the output):

----start here ---


set poll_block "<ul>"

set selection [ns_db select $db "
select poll_id, name, require_registration_p
  from polls
  where poll_is_active_p(start_date, end_date) = 't'
  order by end_date desc, start_date desc

set counter 0

while { [ns_db getrow $db $selection] } {


    incr counter

    append poll_block "
    <li><a href=/poll/one-poll.tcl?[export_url_vars poll_id]>

append poll_block "</ul>"

if {$counter == 0} {
    set poll_block  "No active polls."


<%= $poll_block %>

--- end here ---

Note that I didn't have to do a "ns_db gethandle" because $db is already provided.

I'm also trying to learn this portal stuff, so let me know what you find out.