Users can create new pages on your site if you implement the
Add Page feature. Pages created by users point to new URLs on your site, which can then be found by other users and search engines alike.
Interaction Flow
First, you must add a link or button that triggers the
Add Page process. This launches a dialog that collects information about the new page; some additional information may need to be provided by you at this point. When that dialog is submitted, the user is redirected to a "shell" page on your site.
Place Add Page Link
In the
Client Application, we provide a method to show the
Add Page dialog:
WPCAPI.showAddPageDialog(). Call this method from any link, button, image, or event handler that makes sense for your site. In its simplest form, it could simply be called via an onClick attribute on a link. This method launches the
Add Page dialog.
The parameters for this method include an option to override the default title. For example, if you wanted this link to create pages specifically about album reviews, the dialog title could say, "Add Album Review."
Finally, the method includes parameters to designate a parent cell. That is, if you want pages created by this link to be listed as subpages of a cell, you must pass that cell as the parent cell to this method. Without a parent cell, the new page would have no integrated navigation, which limits its usefulness to both users and search engines.
Note that if a user who clicks on the Add Page link does not have a valid ticket, they will be presented with a
customizable login dialog.
For more information on placing the Add Page link, view the
User-Generated Pages API documentation.
Generate New Cell ID
When a user submits the
Add Page dialog, Injected attempts to generate an ID for the new cell. By default, it will generate a unique ID of its own; however, if you intend to keep track of each new page in your own system, you can override this method to provide your own ID.
For more information on generating new cell IDs, view the
User-Generated Pages API documentation.
Generate New Cell URL
Immediately after the ID is generated, Injected attempts to generate a URL for the new cell. By default, it will simply append the new cell's ID to the querystring of the current page. It is highly likely that you will need to override this method to provide your own formatting to the URL (see
Create Shell Page, below).
For more information on generating new cell URLs, view the
User-Generated Pages API documentation.
Create Shell Page
Once the URL has been generated, the new cell is fully created. When that is complete, the
Add Page dialog automatically redirects the user to the new cell's URL. This URL must be interpreted by your environment, finding information such as the cell ID and the cell Name. With that information, this shell page can have the cell's name as the
<title> of the page as well as the
<h1> (for SEO benefits) -- and it can add the cell to its content.
This shell page should perform every action that other pages perform:
authenticate users,
add user-generated content,
request the client application,
customize interface styles,
customize the login dialog, and (if you want user-generated pages to be able to create other user-generated pages)
implement user-generated pages. Additionally, if you want default content on user-generated pages,
implement templates on them.
Link To Your New Pages
If you are allowing user-generated pages, be sure to use the
CellService.getCellWithChildren call when you retrieve the content area (as shown in
step 2 of this guide). This call automatically provides a simple navigation to the child pages of that cell, allowing for your users and search engines to discover these new pages. To create a more customized navigation, refer to the next step in this guide.
Next -> Step 7:6: BuildCustomize Your OwnLogin NavigationDialog