![]() |
Quote:
|
viewlisting.tpl.php
What files do I need to edit to implement this code in the viewlisting.tpl.php
I want to call some extra field values more than once on this page |
Quote:
php script files have names like "myscript.php" template files have names like "mytemplate.tpl.php" script files have the php code in them and do various things then pass variables from from the executing script to the template where they are displayed. Now, the template that shows us the table with a list of ads is called "showlistings.tpl.php" or alternatively showlistings2.tpl.php. By default this table can only display the default ad fields. These are fields that are predefined. Extra fields that are created via admin and assigned to various categories via the site administration are stored in a separate database table and linked to the ad when an individual ad is viewed. To display these "extra fields" in one of the showlistings templates we have to modify the php code of the scripts that send veriables to showlistings templates and have them not only collect default ad data but read in the extra fields and assign them to variables so they can be passed to the templates for display. The first step is to identify what scripts pass data to the showlisting template. The easiest way to do that is to open the template file layout.tpl.php and at the very top of the file add this.... {debug} save the file, clear the contants of /templates_c folder. Once thats done goto the page you want simply navigate around your site and when you find a page showing you the table where you want extra field data added. When you first hit your site after adding {debug} it will cause a window to popup which will contain valuable information about variables passed from the underlying script to the template being displayed. Now, if you goto your sites home page, then select your "spain" category, then the "Costa del Sol" subcategory to display the overview of available listings. Now look at the popup debug window. At the top you should see something like...... included templates & config files (load time in seconds): layout.tpl.php (0.05427) (total) categories/subcategories.tpl.php (0.04858) showlistings2.tpl.php and just below that...... assigned template variables: {$SCRIPT_NAME} /category.php That tells us that when you are viewing the overview of listings in the subcategory "Costa del Sol" under the main category "Spain" that the script doing the work is "category.php" and that there are 3 templates involved in displaying the data provided by the script "category.php". As we allready have surmised the template showlisting.tpl.php is the one that actually creates the table and displays the various ads available in a given category. But now we need to find out what other scripts may also call it. This is where you would move around your site looking for places where something similar to the table of ads is displayed when we are looking in a cetegory. You will notice that if we do a search, the resulting page displayed has a similar table of ads and if we look at the debug info we see once again the template showlistings is called. ncluded templates & config files (load time in seconds): layout.tpl.php (0.04570) (total) showlistings2.tpl.php (0.03987) assigned template variables: {$SCRIPT_NAME} /searchresults.php if we look around a little more and select the "top listings" link and check debug we see something like this.... included templates & config files (load time in seconds): layout.tpl.php (0.04774) (total) showlistings2.tpl.php (0.04190) assigned template variables: {$SCRIPT_NAME} /toplistings.php Now we know we have 3 php scripts that are responsible for for passing data to the showlistings template.....ie category.php searchresults.php toplistings.php So we need to modify each one of these files so that they grab the extra field data so it can be passed along to showlistings template. That is where my little chunk of code comes into play. Are you with me so far? |
Sorry if this is a little off topic here but I notice you are recieving page load times in your debugger. I dont have these and never have had. They would be a fantastic tool for me. Is there way to turn this on?
|
Quote:
I believe the debug console uses the microtime() function to determine execution time and its only available on operating systems that support the gettimeofday() system call. So if your not seeing it, its likely due to the OS of the server hosting your site. |
Ok, Im running apache on my local test machine (windows xp).
Hmmm.. this would be so useful to me. I will enquire further, thanks Larry:o |
Quote:
|
Im with you there and all my live sites run on linux, but my laptop runs windows.
|
Quote:
|
viewlisting.tpl.php
Hi Iv got this code working fine, but Im trying to use it in viewlisting.tpl.php
I tryed to insert it into viewlistings.php but it gave me errors |
| All times are GMT -4. The time now is 10:52 PM. |
Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.