Index: openacs-4/packages/acs-core-docs/www/tutorial-pages.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/tutorial-pages.html,v diff -u -N -r1.35 -r1.36 --- openacs-4/packages/acs-core-docs/www/tutorial-pages.html 16 Feb 2005 00:21:03 -0000 1.35 +++ openacs-4/packages/acs-core-docs/www/tutorial-pages.html 4 Jun 2006 00:45:25 -0000 1.36 @@ -1,8 +1,9 @@ -Creating Web Pages

Creating Web Pages

by Joel Aufrecht

+ +Creating Web Pages

Creating Web Pages

by Joel Aufrecht

OpenACS docs are written by the named authors, and may be edited by OpenACS documentation staff. -

Install some API

As a workaround for missing content-repository functionality, copy a provided file into the directory for tcl files:

-    cp /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/acs-core-docs/www/files/note-procs.tcl /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/tcl/

To make this file take effect, go to the APM and choose "Reload changed" for "MyFirstPackage".

Page Map

Our package will have two visible pages. The first shows a list of all objects; the second shows a single object in view or edit mode, and can also be used to add an object. The index page will display the list, but since we might reuse the list later, we'll put it in a seperate file and include it on the index page.

Figure�9.5.�Page Map

Page Map

Build the "Index" page

Each user-visible page in your package has, typically, +

Install some API

As a workaround for missing content-repository functionality, copy a provided file into the directory for tcl files:

+    cp /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/acs-core-docs/www/files/note-procs.tcl /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/tcl/

To make this file take effect, go to the APM and choose "Reload changed" for "MyFirstPackage".

Page Map

Our package will have two visible pages. The first shows a list of all objects; the second shows a single object in view or edit mode, and can also be used to add an object. The index page will display the list, but since we might reuse the list later, we'll put it in a seperate file and include it on the index page.

Figure�9.5.�Page Map

Page Map

Build the "Index" page

Each user-visible page in your package has, typically, three parts. The tcl file holds the procedural logic for the page, including TCL and database-independent SQL code, and does things like @@ -22,29 +23,29 @@ set page_title [ad_conn instance_name] set context [list]

Now index.adp:

<master>
-  <property name="title">@page_title;noquote@</property>
-  <property name="context">@context;noquote@</property>
-<include src="/packages/myfirstpackage/lib/note-list">

You can test your work by viewing the page.

The index page includes the list page, which we put in /lib instead of /www to designate that it's available for reuse by other packages.

[$OPENACS_SERVICE_NAME www]$ mkdir /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/lib
+  <property name="title">@page_title;noquote@</property>
+  <property name="context">@context;noquote@</property>
+<include src="/packages/myfirstpackage/lib/note-list">

You can test your work by viewing the page.

The index page includes the list page, which we put in /lib instead of /www to designate that it's available for reuse by other packages.

[$OPENACS_SERVICE_NAME www]$ mkdir /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/lib
 [$OPENACS_SERVICE_NAME www]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/lib
 [$OPENACS_SERVICE_NAME lib]$ emacs note-list.tcl
template::list::create \
     -name notes \
     -multirow notes \
-    -actions { "Add a Note" note-edit} \
+    -actions { "Add a Note" note-edit} \
     -elements {
 	edit {
 	    link_url_col edit_url
 	    display_template {
-		<img src="/resources/acs-subsite/Edit16.gif" width="16" height="16" border="0">
+		<img src="/resources/acs-subsite/Edit16.gif" width="16" height="16" border="0">
 	    }
 	    sub_class narrow
 	}
 	title {
-	    label "Title"
+	    label "Title"
 	}
 	delete {
 	    link_url_col delete_url 
 	    display_template {
-		<img src="/resources/acs-subsite/Delete16.gif" width="16" height="16" border="0">
+		<img src="/resources/acs-subsite/Delete16.gif" width="16" height="16" border="0">
 	    }
 	    sub_class narrow
 	}
@@ -61,9 +62,9 @@
                mfp_notesx n
         where  n.revision_id = ci.live_revision
     } {
-	set edit_url [export_vars -base "note-edit" {item_id}]
-	set delete_url [export_vars -base "note-delete" {item_id}]
-    }
[$OPENACS_SERVICE_NAME lib]$ emacs note-list.adp
<listtemplate name="notes"></listtemplate>

Create the add/edit page. If note_id is passed in, + set edit_url [export_vars -base "note-edit" {item_id}] + set delete_url [export_vars -base "note-delete" {item_id}] + }

[$OPENACS_SERVICE_NAME lib]$ emacs note-list.adp
<listtemplate name="notes"></listtemplate>

Create the add/edit page. If note_id is passed in, it display that note, and can change to edit mode if appropriate. Otherwise, it presents a form for adding notes.

[$OPENACS_SERVICE_NAME lib]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/www
 [$OPENACS_SERVICE_NAME www]$ emacs note-edit.tcl
ad_page_contract {
     This is the view-edit page for notes.
@@ -82,7 +83,7 @@
 } -new_request {
     auth::require_login
     permission::require_permission -object_id [ad_conn package_id] -privilege create
-    set page_title "Add a Note"
+    set page_title "Add a Note"
     set context [list $page_title]
 } -edit_request {
     auth::require_login
@@ -93,7 +94,7 @@
 
     set title $note_array(title)
 
-    set page_title "Edit a Note"
+    set page_title "Edit a Note"
     set context [list $page_title]
 } -new_data {
     mfp::note::add \
@@ -103,14 +104,14 @@
 	-item_id $item_id \
 	-title $title
 } -after_submit {
-    ad_returnredirect "."
+    ad_returnredirect "."
     ad_script_abort
 }
[$OPENACS_SERVICE_NAME www]$ emacs note-edit.adp
<master>
-  <property name="title">@page_title;noquote@</property>
-  <property name="context">@context;noquote@</property>
-  <property name="focus">note.title</property>
+  <property name="title">@page_title;noquote@</property>
+  <property name="context">@context;noquote@</property>
+  <property name="focus">note.title</property>
   
-<formtemplate id="note"></formtemplate>

And the delete page. Since it has no UI, there is only a +<formtemplate id="note"></formtemplate>

And the delete page. Since it has no UI, there is only a tcl page, and no adp page.

[$OPENACS_SERVICE_NAME www]$ emacs note-delete.tcl
ad_page_contract {
     This deletes a note
 
@@ -126,7 +127,7 @@
 set title [item::get_title $item_id]
 mfp::note::delete -item_id $item_id
 
-ad_returnredirect "."
+ad_returnredirect "."
 # stop running this code, since we're redirecting
 abort
 
View comments on this page at openacs.org