11-11-2009, 07:30 AM
|
#1
|
Confirmed User
Industry Role:
Join Date: Nov 2008
Posts: 2,491
|
webcams.com - Mastering the RSS Feed Parser like a pro - [tutorial part 2]
We will continue with the second part of the tutorial:
- Implementation of the template page used for pagination
- Implementation of the template page used for profile display
For those that didn't read the first part of the tutorial, it can be found here: webcams.com - Mastering the RSS Feed Parser like a pro.
So we've prepared the templates in the end of the first part of this tutorial and now we will insert the RSS PHP parsed variables from the FEED inside them.
Go to the affiliate area -> Promo Tools -> RSS Feeds -> RSS Parser: PHP based -> and search after PHP Tags and Available Variables.
We will find here some technical info regarding the parser's functionality and some necessary info such as the name of all the variables that display the info in your templates.
So let's start with the "Implementation of the template page used for pagination".
Step 1 Let's open the online_models_paging.php. On the first line we can see that the WEBCAMS.COM parser is called ...
Let's make sure that it will be permanently available for this pages.
To do this we will create a new directory inside online&pagination, next to online_models_paging.php and profile. Let's say that you will name it "feeds".
Step 2 So we have the directory. Now let's move the WebcamsRSSParser.php from
the main archive directory to "feeds?" directory. Once we've done that we will change the path in the online_models_paging.php, from "../WebcamsRSSParser.php".
to "feeds/WebcamsRSSParser.php"
Step 3 Copy the template files in the same directory with online_models_paging.php named online&pagination.
Let's rename the main template file, the one where we want the pagination to be displayed. We will name it "index" and the extension will be php. After this operation we will open it in a text editor and start the implementation.
Step 4 We have both files, index.php and online_models_paging.php, opened in the editor. We will copy the first part of php code from online_models_paging.php starting from
Code:
<?php require_once('feeds/WebcamsRSSParser.php');
and ending with
Copy and paste above the header of the template.
As you have noticed the online_models_paging.php has an internal style with classes in the header. There is no need to keep that one if we have our own style in the new template, so we jump over the header and we stop on the first php tag, which is
Code:
<?php if($noOfPages>1){?>
This is the pagination. I assume that we have a certain location especially dedicated in the new layout. If we don't, let's create one and modify the template a little bit. The pagination div/table will be in a visible place. Most of the times it is positioned above the model thumbs. Once we have done that we will start to copy from
Code:
<?php if($noOfPages>1){?>
until the last curly bracket Step 5 Now you have to insert the foreach that will repeat the process of displaying movies for each model apart. What we have to do is to identify and prepare the spot in the new layout where we want to place the thumbs of the models. Let's move to the next php start tag code
Code:
<? foreach($models as $model) {
and copy until
Step 6 Start Xampp, open the browser and type : http://127.0.0.1/online&pagination/index.php.
You should see some changes in there, something dynamically is being loaded.
You will see the pagination and the model thumbs. I assume that we have a certain number of model thumbs per line and a certain style per thumb. Well let's go back in the index page and identify the last place where we've made changes and search after foreach. Once found, we will solve the problem regarding displayed thumb limitation per line. We will basically change the old foreach with the new one.
Code:
<? foreach($models as $model) {
with this other one
Code:
<? foreach($models as $key=>$model) { if($key % 5 == 0) echo
"</tr><tr>" {
So, what have we changed and what's the difference. Let's analyze it in detail:
Code:
if($key % 5 == 0) echo "</tr><tr>"
5 represents the number of thumbs per line
Represents the table row, it can be easily changed with But to use this two methods we will need to add another two parameters.
In the case of the table the one with:
we will add above this tag
Code:
<? foreach($models as ;
Code:
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
and below
we will add
In the case of div it will be:
Code:
<div class="main"><div class="model">
and below
we will add
Don't forget to add the class on the table or div that will help you make the styling.
Implementation of the template page used for profile page
How does it work: the $_REQUEST['model_id'] gets the numeric ID and uses the parser to get the model details by calling the feed of the requested model. So we've prepared the templates last week and now we will insert the RSS PHP parsed variables from the FEED inside them.
Go to the "affiliate area -> Promo Tools -> RSS Feeds -> RSS Parser: PHP
based -> and search for PHP Tags and Available "Variables".
Here we will find some technical info regarding the parser's functionality and some other necessary info, such as the name of all the variables that display the info in your templates.
So let's start with the "Implementation of the template page used for profile page".
Open the profile.php file, and change the path of the parser from "../WebcamsRSSParser.php" to "feeds/WebcamsRSSParser.php"
Copy the first part into the template file of the profile page. We will insert it exactly in the same spot as it was copied from, at the top that is.
As you may see, there are a lot of variables on this page. All of them are adjustable and begin with
Code:
$model-> (this is were the called parameter is situated). For example: $model->sex_pref;
$model->measurements; $model->eye_color; $model->about_me;
You can find a complete list with all the available variables here: Affiliate area -> Promo Tools -> RSS Feeds -> RSS Parser: PHP based ->and search after PHP Tags and Available Variables
Complete the rest of the template with the variables you want and your done with the profile display.
Below you can see that there is a foreach that indicates other suggestions (online models). This can also be adapted.
We will use the same method as we did for pagination, or we can simply create a style for the existing structure and adapt it. And it seems we are done with this part of tutorial also.
Hope to be helpful!
|
|
|