3.2.2.7 The php functions used for interface models
The Siteseed pre-defines many functions, in the php language, enabling the use of the many Siteseed functions.
Survey functions:
The survey functions allow the insertion of surveys and their respective results into the website. The available surveys are defined by the editor menu, in the back office.
In order to use the survey functions, the following code line is always to be included in the interface model:
include 'include/surveys.php';
Functions:
print survey ($id, $url, $button, $strResults, $urlResults);
Function which prints the survey questionnaire.
Parameters
$id - questionnaire number
$url (optional)- address to where the user is redirected after voting
$button (optional) - text or image where the button is to be used
$strResults (optional) - text of the link to the address $urlResults
$urlResults (optional) - address containing results
print survey_results ($id, $strBeforeVote, $strAfterVote, $question);
Function which prints the results of the survey questionnaire;
$id - questionnaire number
$strBeforeVote (optional)- text to be printed before each vote is counted
$strAfterVote (optional)- text to be inserted after each vote is counted
$question (optional) - print only the survey results for the chosen question. By default prints all question results.
note: vote counting will only be printed if there is at least one of these text variables.
Navigation bar insert function
The Siteseed provides for the automatic insertion of navigation bars. Hence, links to the website sections are managed by the system. Whenever a section is created or removed from the section management menu, this modification will automatically be reflected in the website interface. The said functions also allow a navigation support bar to be inserted. This allows us to go back to sections located higher up the hierarchical structure.
-Functions:
back_navigation_bar ($formato_link, $separador, )
Makes the navigation support bar available, with a link to sections higher up in the hierarchy.
Parameters
$formato_link - format of the parameters to be displayed in the URL section
$separador - character used to separate the sections contained in the bar
Example:
Check the FAQ on how to implement navigation bars.
area_name()
A function to retrieve the name of the area where the website user is.
XML import
Siteseed allows you to implement links to other sites (or import full articles) with its XML import fuctions.
<?
include "include/xmlparse.php";
$gildot=XMLparse("http://www.gildot.org/gildot.xml");
# or use
# $gildot=XMLparse("/path/to/dump/gildot.xml");
# to read from a local file
$article_title=$gildot["backslash"]["#"]["story"][0]["#"]["title"][0]["#"];
print("$article_title");
?>
To check what the "funny" array structure mean check the "XML Edit" option on your backoffice menu (last item on the "Technical Staff" menu).
You can parse the data as you wish using while()/for() to display the items imported (or link to them).
User authentication
Siteseed allows access to certain areas of a website otherwise restricted through a user registration system. Hence, in interface models, it is possible to check whether the users have identified themselves with a system login and password prior to certain information being made available.
The system saves, in the variable $session_id , the status of the section, that is, whether the authentication process for a certain user did or did not take place.
The function get_user_data() allows us to obtain the information contained in a certain user file field. If, for example, in the backoffice four fields are defined for each user: login, password, name and e-mail, using the function get_user_data and if the user is authenticated (having typed in his/her login and password successfully) it is possible to obtain the name of the user, or any other of the four fields, through the function get_user_data(name).
Example of a code used in an interface model for managing user authentication:
In the submitted code, the first clause checks whether the user has been authenticated by the system, through his/her login and password. If this condition is met, we can use the function get_user_data(), in order to obtain the user login which in turn appears on the system?s interface. Immediately after the login the hyperlink to the user data edit form (page object with id 20) will appear. If the user is not authenticated, the system will make the authentication form available, as inserted in page object with id 19, through the command INSERT form .
Search engine
The Sitemaker search engine allows us to search the text content contained in articles on the website. Hence, whenever an article is saved in the back office, the system registers the contents of its fields, as long as they are defined as searchable. The definition of searchable fields is made from the option ?Fields? in the Articles menu in the back office technician interface.
The search engine allows for a search of contents based on a word or set of words. Should a search be made using more than one word, then there are two different possibilities: on the one hand, searching an article based on both of the words. That is, for example, should we search for 'my dog', the search system finds all texts containing either the word 'my' or the word 'dog'. Where we intend to search an article with a certain word sequence, then we should begin and end the set of words with speech marks. That is, where we intend to search for the expression 'my dog', then we ought to write ' "my dog" ' in the search text.
The insertion of search options in the website is made based on a HTML form with a text field. The name of the text field ought to be ?search?. The form results in the file ?index.php? being retrieved.
Optionally the ?visual? parameter can be used to indicate the layout model for the search results. The ?visual? parameter is to be a ?hidden? type form field.
Example of a simple search form in HTML:
Note: In the form, a ?hidden? field is used to indicate layout model 6 in use for displaying results.
|
|