![]() |
Showlistings2.tpl.php help
Hi I need and bit of help on the showlistings template, Im not to hot on php but Im willing to get to know this script.
Im wanting to use this for a holiday rental site and Im trying to call bits of information from the database, like, advertisers area, city, number of bedrooms and type of property, also have email a friend link for the showlistings page Thanks Glenn |
I take it these will 'all' be 'extra fields' (administration > category > extra fields) ?
|
Iv tryed using something like this {$extra.5.value}
and I cant get the email link to call advert ID number |
Glen,
I still need to know if you are going to use 'extra fields' or not. This is a question. Quote:
|
yes I was planing to use these fields, but can I adjust the places these fields show up in showlisting.temp.
Also if a member has more than one property in different locations the wrong area will be displayed in the showlistings page |
For the email a friend link, you have probably used this:
Code:
<a href="javascript:void(0);" onclick="MM_openBrWindow('{$smarty.const.URL}/friendmail.php?vehicle={$listingid}','contact','width=350,height=400')">{$smarty.const.LANG_EMAIL_FRIEND}</a>That works. You mentioned 'showlisting.temp' - that's a new one on me. Where is that? |
Sorry I mean showlistings2.tpl.php, I think its best to use extra fields for all advert information, because some people have rentals all over the place.
Also that {$entryid} code didnt work for me thanks for your help |
Sorry - it should be {$entry.id}
To add the extra fields into showlisting2, go down to Maffo's entries here..... http://www.68classifieds.com/forums/...0048#post10048 If you get stuck, yell out here and we will be able to help you. This is a great modification. |
Yes please help me, I need to use extra fields on showlistings.tpl.php
only because a lot of people have property in different areas and in different countries. from what I understand I need to insert this code to display info from extra fields Iv made up for property details what I need to know is where the code gets inserted and if I need to re-peat code if I call same data more than once. extra fields that I would like to use in showlistings2.tpl.php are Location: text input Sleeps: drop select Price: text input state: text input country:text input thanks for your help |
Quote:
Please provide the information requested below and please be very specific. If you say 'extra fields', I will think you are referring to these (administration > categories > extra fields). If you are NOT referring to these, please call any other fields 'additional fields' so that we don't get confused. 1. Which of these above are 'extra fields' and what are their IDs (administration > categories > extra fields ......... the IDs are beside the name of the extra field) 2. Which of these above are fields you have added to the 'user registration' form? I need to know if they are extra, extra2, extra3. 3. Is 'price', 'state' and 'country' using the normal 68 classifieds fields .... or are these additional fields/extra fields? |
I will not be using any of the "User Registration Fields"
these are the 'additional fields' IDs Location: id - 9, called x1 Sleeps: id - 11, called x1 Type: id - 5, called x1 Price: id - 7, called x1 state: id - 10, called x3 country: id - 8, called x1 is it possible to have cheap flights to "state, country" |
Question - whereabouts in 'administrationm' did you add these fields? Please be very specific.
Also, what does 'called x3' mean? .... as in ....'state: id - 10, called x3' |
I made these fields up in /administration/fields.php.
'state: id - 10, called x3', means I would like to use state data 3 times on showlistings2.tpl.php like for cheap travel insurace for "state" cheap car hire in "state" cheap flight to "state, country" credit card trasfur Email A Friend "called X3" means I would like to insert state info 3 times on the same page |
Ok - now I understand - these are called 'extra fields'.
Open up the files category.php, searchresults.php and toplistings.php. They are situated in your root directory of the classifieds script. In these files you will see this: Code:
//now get the imagesQuote:
Now open up showlistings2.tpl.php. Where you wish to have 'location' displayed, add this: {$entry.mafExtralocation} Where you wish to have 'sleeps' displayed, add this: {$entry.mafExtrasleeps} Where you wish to have 'type' displayed, add this: {$entry.mafExtratype} etc, etc. Let's know how you go. I'm sure many others will use this modification - it's very simple (when you know how) and very powerfull. Thanks to maffo for the help with this one. |
Iv got the designer copy of 68, I need to upgrade or can you do it with out developer copy??
thanks for your help and time, this is a HOT HACK |
An upgrade is the only way im afraid but worth every penny.
|
I have one site ive been working on which is largely informational and I have nearly 70 fields that I want people to be able to see "at a glance" so I wanted them on the showlisting level. What I did was used the following code to grab all the extra fields. It then adds them to the current $row array with a key that equals their fieldname. The $row array is later assigned to $result and passed to the template.
here is my little code snipped to get and pass the extra fields. Code:
$extra=array(); |
Now thats efficiency!
Thats how it should be written when wanting more than one field. 70 extra fields???:confused: :confused: |
Hi Larry, on what pages did you use this code, do I still need the upgrade
Also if I upgrade to the developer 68 what files do I need to save, So I dont loose all the changes Iv made so far |
Quote:
Im doing away with the left nav and will be using a DHTML menu across the top, ive just been too busy to redo the layout. Quote:
It would need to be added to the same 3 files Chaslie mentioned (ie category.php, searchresults.php and toplistings.php) |
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 |
Quote:
|
Im calling using {$extra.??.value} but for some reason its only working on a few extra fields,
the extra frields Im trying to use are single line text boxes |
Quote:
The viewlisting.php file assigns the extra field data to a multidimensional array called extra and the viewlisting.tpl.php file uses the following smarty template code to iterate over the array of arrays (multidimensional array). Code:
{foreach from=$extra item=extras}The number of extra fields passed by default behavior can vary from category to category depending on what extra fields you have defined. When in doubt, use the smarty debug console to see what fields are passed as I mentioned in my above post. |
sorry I dont know what going on the {debug} is not working for me
I get this: Warning: Smarty error: [in layout.tpl.php line 1]: syntax error: plugin function smarty_function_debug() not found in /home/fhlinux198/c/cheapholidayrentalsdirect.com/user/htdocs/includes/classes/smarty/plugins/function.debug.php (Smarty_Compiler.class.php, line 798) in /home/fhlinux198/c/cheapholidayrentalsdirect.com/user/htdocs/includes/classes/smarty/Smarty.class.php on line 1095 |
Try uploading your smarty plugin directory again:
includes/classes/smarty/plugins |
| All times are GMT -4. The time now is 10:55 PM. |
Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.