The best way to learn how to use the WebCore is by example. See the documentation for more information.

The requested URL is always shown first; if a page uses one or more WebCore templates, those are shown afterwards.

00 <?php
01   require_once ('webcore/init.php');
02  
03   $Page->template_options->title = "Oz";
04   $Page->title->subject = "Oz's Home Page";
05  
06   $Page->location->add_root_link ();
07   $Page->location->append ("Oz");
08  
09   $Page->start_display ();
10  
11   $oz_page = read_var ('oz_page');
12   $friends_page = read_var ('friends_page');
13  
14   include_once ('albums/init.php');
15   $albums_app = $Page->make_application (Album_application_id);
16  
17   $folder_query = $albums_app->login->folder_query ();
18 ?>
19 <div class="main-box">
20   <div class="columns text-flow">
21     <div>
22       <h2>Bio</h2>
23       <p>I'm a mixed dwarf rabbit. I rule
24       my apartment with an iron fist. I live in New York City (in
25       Queens). Every once in a while, I'm transported upstate in
26       the loudest car in the world for a 'Fresh Air' weekend. The
27       warden there took some pictures of me. Check 'em out here.</p>
28       <h2>News</h2>
29       <?php
30         /** @var ALBUM $folder */
31         $folder = $folder_query->object_at_id (19);
32         if ($folder)
33         {
34           $journal_query = $folder->entry_query ();
35           /** @var JOURNAL $journal */
36           $journal = $journal_query->object_at_id (1989);
37           $creator = $journal->creator ();
38  
39           echo $journal->description_as_html ();
40       ?>
41       <p class="info-box-bottom"><?php echo $creator->title_as_link (); ?> - <?php echo $folder->format_date ($journal->date); ?></p>
42       <?php
43         }
44       ?>
45       <h2>Latest Photos</h2>
46       <?php
47       if ($folder)
48       {
49         $pic_query = $folder->entry_query ();
50         $pic_query->set_type ('picture');
51         $pic_query->set_order ('entry.date DESC');
52  
53         $class_name = $albums_app->final_class_name ('PICTURE_GRID', 'albums/gui/picture_grid.php');
54         /** @var PICTURE_GRID $grid */
55         $grid = new $class_name ($albums_app);
56         $grid->pager->page_number_var_name = 'oz_page';
57         $grid->pager->page_anchor = 'photos';
58         $grid->set_page_size (Default_page_size);
59         $grid->set_query ($pic_query);
60         $grid->display ();
61       }
62       else
63       {
64         echo "<span class=\"error\">The oz autobiography album is unavailable.</span>";
65       }
66       ?>
67     </div>
68     <div class="right-sidebar">
69       <h2>Links</h2>
70       <ul>
71         <li><a href="care_and_feeding.php">Care and Feeding</a> (personalized)</li>
72         <li><a href="nids_journal.php">Nid's Journal</a> (April 2002)</li>
73       </ul>
74       <h2 id="friends">Friends</h2>
75       <?php
76       $folder = $folder_query->object_at_id (41);
77       if ($folder)
78       {
79         $pic_query = $folder->entry_query ();
80         $pic_query->set_type ('picture');
81         $pic_query->set_order ('entry.date DESC');
82  
83         $page = $friends_page;
84  
85         $class_name = $albums_app->final_class_name ('PICTURE_GRID', 'albums/gui/picture_grid.php');
86         $grid = new $class_name ($albums_app);
87         $grid->pager->page_number_var_name = 'friends_page';
88         $grid->pager->page_anchor = 'friends';
89         $grid->pager->pages_to_show = 2;
90         $grid->pager->show_total = false;
91         $grid->pager->show_first_and_last = false;
92         $grid->css_class = 'grid full-width';
93         $grid->set_page_size (Default_page_size);
94         $grid->set_query ($pic_query);
95         $grid->display ();
96       }
97       else
98       {
99         echo "<span class=\"error\">The friends album is unavailable.</span>";
100       }
101       ?>
102       <h2>Poll</h2>
103       <?php
104       require_once ('plugins/com.earthli.polls.init.php');
105  
106       $poll_app = make_poll_application ($Page);
107       $poll_query = $poll_app->poll_query ();
108       /** @var POLL $poll */
109       $poll = $poll_query->object_at_id (1);
110       if ($poll->can_vote ())
111       {
112         $poll->post_page_name = "polls/record_poll.php";
113         $poll->redirect_page_name = "/users/oz/index.php";
114  
115         /** @var POLL_FORM $form */
116         $form = $poll->form ();
117         $renderer = $form->make_renderer ();
118         $form->display ($renderer);
119       }
120       else
121       {
122         $poll->display_results ();
123       }
124       ?>
125       <h2>Live</h2>
126       <p>Sometimes you can see me on the <a href="/webcam/index.php">earthli Webcam</a>.</p>
127     </div>
128   </div>
129 </div>
130 <?php $Page->finish_display (); ?>
131