Support Forums

smarty debug - getting variables

This is a discussion on smarty debug - getting variables within the Modules / Plugins / Modifications forums, part of the Developer Forums category; In the smarty debug console I can see an array of variables generated from searchresults.php I would like to use ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

This topic is closed.

This topic is closed to new replies.

 
Thread Tools Display Modes
Old 07-06-2008, 06:29 AM   #1
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default smarty debug - getting variables

In the smarty debug console I can see an array of variables generated from searchresults.php I would like to use one of them in the layout.tpl file.

I see something like this

{$results} Array (10)
0 => Array (22)
id => "516"
owner => "43"
title => "BORDEAUX - EXTRAORDINARY CHATEAU"
featured => "N"
section => "1"
.
.

I would like to get hold of the title => part of the array and use it in a metatag. Something like

<title>French Property For Sale - BORDEAUX - EXTRAORDINARY CHATEAU</title>

how do I access or call it?
seymourjames is offline  
Old 07-06-2008, 08:32 AM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,393
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

{$results.0.title} will grab the title from the first array within the array.

http://www.smarty.net/manual/en/language.variables.php
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 07-06-2008, 09:39 AM   #3
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default

thanks - I looked in the forum but did not find an answer. This will allow some neat tricks to be done with metatags on the searchresults pages.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates and list your 68C site on ClassifiedCodes.com
seymourjames is offline  
Old 07-06-2008, 02:55 PM   #4
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default

Is there a way to get the value of the 'type' variable in showlistings.tpl or preferably in layout.tpl when using the designer version.

For example {$smarty.get.type} = an integer

What I would like is the category string itself like the category slug.

Same thing with

{$smarty.get.owner} = an integer

I would like to access the actual username for example. Looking at the smarty manual is not helping on this occasion or I am missing it.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates and list your 68C site on ClassifiedCodes.com
seymourjames is offline  
Old 07-06-2008, 05:46 PM   #5
curmudgeon
 
Join Date: Mar 2006
Posts: 5,393
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by seymourjames
Is there a way to get the value of the 'type' variable in showlistings.tpl or preferably in layout.tpl when using the designer version.

For example {$smarty.get.type} = an integer

What I would like is the category string itself like the category slug.

Same thing with

{$smarty.get.owner} = an integer

I would like to access the actual username for example. Looking at the smarty manual is not helping on this occasion or I am missing it.
Im not quite following where you came up with $smarty.get.type or $smarty.get.owner.

the "get" in the above examples is looking to "get" the value of the variable called "type" from the URL.

If you had a URL in the browser that looked like this.....

http://mysite.com/index.php?type=12

$smarty.get.type would display 12

http://www.smarty.net/manual/en/lang...les.smarty.php
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 07-06-2008, 06:20 PM   #6
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default

Hi Larry,

Exactly. I am getting those from the url generated by searchresults.php but what I really would like to do is know that if I have type=12 in the url then category = california for example (the search was on the category called california). One way is to do a big case statement (logicaly)

case 0: all regions
case1: nebraska
case2: wyoming

Etc.

It would be clumsy to test for every category that way of course. The reason I want to get the category (corresponding to that type) is so I can write nice metatags for the search results page. Likwise if it is a search results page which come from 'more ads from seller'. I would like to know who the owner is (a string), not just owner=5 or whatever (who is number 5?).

Could I not query the database to ask who owner number 5 is or what is category 7? Not sure about how I would do that.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates and list your 68C site on ClassifiedCodes.com
seymourjames is offline  
Old 07-07-2008, 03:22 PM   #7
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default

Does anyone know how to get the category or owner string (the text) from a search into the showlistings or layout files?
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates and list your 68C site on ClassifiedCodes.com
seymourjames is offline  
Old 07-07-2008, 05:35 PM   #8
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,342
Rep Power: 50
Maffo is just really nice Maffo is just really nice
Default

The best way to do this is get the Developers Edition as you get the entire code. As you are wanting to make alterations, you will be able to make alterations as well as learn PHP. $99 to learn PHP
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 07-07-2008, 05:44 PM   #9
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,342
Rep Power: 50
Maffo is just really nice Maffo is just really nice
Default

Dont take that as offensive Seymour, youve been on this site a while now, thats just where I reckon you should be and as youve pretty much fathomed the html and how smarty works. Now its time for php, sql and the likes.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline  
Old 07-07-2008, 07:01 PM   #10
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,197
Rep Power: 78
seymourjames is a jewel in the rough
Default

Tis true perhaps. There are several things I would like to do. One thing is needed though in my opinion for the designer edition and that is some handy functions which can be called to return variables in all sorts of places - like what category is defined in a search, who is the owner in the search, etc. These are needed in order to build good title tags on pages.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates and list your 68C site on ClassifiedCodes.com
seymourjames is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Smarty Templates and You. Posted BY Lhotch Eric Barnes Templates, HTML, CSS, and Design Help 13 10-02-2007 08:06 AM


All times are GMT -4. The time now is 01:34 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0