This topic is locked
[SOLVED]

 Generate web page content from PHPRunner

7/3/2012 11:28:51 AM
PHPRunner General questions
C
carolp author

Hello,
We are building an application that allows customers to enter content for their individual web page. We:

  1. Assign a URL to the customer
  2. Assign login credentials to the customer


When the customer logs in based on the credentials we've provided, the customer sees a list of editable fields. The customer can fill in these fields with their specific data - quite simple. These pages have been created with PHPRunner.
The idea is that when the customer goes to the specific URL we have assigned them, the web page displays.
Can this be accomplished with PHPRunner? Any specific ideas as to how to go about this? Do we need to use another tool in conjunction with PHPRunner? Thanks so much for your help.

C
cgphp 7/3/2012

Add an external php file to your project, get the current user id session, fetch data for that user from the database and build the html page.
Code example:

<?php

session_start();

$current_user = $_SESSION['UserID'];

include('include/dbcommon.php');
$rs = CustomQuery("SELECT * FROM website_table WHERE UserID='".$current_user."'");

$record = db_fetch_array($rs);
//build html page

...

...

...
E
electromotive 7/4/2012

I believe what the OP is talking about here is whether or not PHPR can easily be used to generate a content management system (a CMS, not just custom pages).
The backend of every CMS and wiki is a database, and PHPR has certainly got that.

The question becomes how to dynamically create the pages for each user, and how to access those pages through a friendly URL.
The wiki scenario is probably easier cause the URLs are easier, you can find all the pages using a search field and go from page to page. If the search returns a number of hits, then display a list, otherwise display a view or dynamically build a page, as shown above. Doesn't matter so much about friendly URLs. The wiki is also easier cause the structure is the same for all the pages.
The CMS is a bit harder and there was an article in the helpful tips on how to create friendly URLs, but you'll need control of your server for rewriting. There may be other URL solutions, and maybe we'll get some more contributions. http://www.asprunner.com/forums/topic/6341-mod-rewrite-for-seo-friendly-pages/
A typical CMS generated page is going to have a number of panels, and in those panels you are going to want to display different types of content - formated text, images, videos, links to your other pages, reader comments, etc, you know the stuff. The page may also contain tabs and dropdowns to access more of the member's content. All this stuff can be stored in the DB for each member. Different members will likely want different page layouts, so not only does the DB contain the content data, but also the metadata, how to present it. If the member allows reader comments (or tweets), then the DB has to store these. While you can custom code all of this, the benefit of a CMS is that there is a template mechanism which allows all "members" to easily create their structure and content over the web without any coding. So what we have to build on top of PHPR is a CMS templating application.
As with all these things, you start off incrementally, develop a structure, the basic elements, then refine and develop it. To develop the idea proposed above, there are essentially two parts. There's the PHPR DB and forms to capture the content and meta-structure, and then there's a PHP script which gets called to read the DB and display the page for each member. Both will be developed in unison, but let's start with the PHPR side.
Lets assume to start you have a typical simple page structure - a top panel, left and right side panels, a central panel, and a bottom panel (5 panels). These don't all have to be active. Lets also assume we are able to use the builtin Rich Text Editor to place all the content, including images, but accept for now you are not going to get a What You See is What You GET (WYSIWYG) content editor at the outset at least. Create a table to hold the page content with 5 tabs, one for each panel. Maybe put a switch in each to indicate whether the panel is active, maybe some dimensional information, background and foreground colors, etc, all indexed off the member, and which page, and a page name. Let's just assume a simple URL name like site_name?a=member&page=pagename. Page is optional, if not supplied it just goes to the members "home page". Sort out url rewriting later.
Now take the sample code from above and start a PHP script to display the pages (one script displays the content for all users and pages, for now).

When the page is called, get the parameters, including the user name and page, read the DB record and get all the content. The page has html structural elements (like tables, divs & spans) setup for the panels, but these can be hidden and dynamically activated based on the content. The PHP script will need to do some error checking, as the content could be crap and have no hope of fitting into the structure. Make it as smart as it needs to be (ie., image resizing, jquery, etc), have a debug mode to display the formating issues while the member is creating the page, then turn that off when done. Both pages can be open at the same time, the content creation page and the display page. You'll need to write this PHP script, begging and borrowing. 50 lines of code should get you running.
You can make things a lot easier by just having a few templates for layout options. Maybe start with two templates. By having the member chose an initial template when they start to create the page, in PHPR you can dynamically tailor the content forms to support that template, and of course the PHP script also knows what to do with each template.
Note. Exactly the same process can be used to create PDF documents and highly customised structured forms, labels, and reports.