how to get the object I want in search result list

how to get the object I want in search result list

Postby chan15 on Fri Apr 11, 2008 12:31 pm

I hope every list have author of the article at the bottom
in main.template is like below

{foreach from=$posts item=post}
{assign var="postOwner" value=$post->getUserInfo()}
{$postOwner->getUsername()} under
{/foreach}

but I don't know how to get it in searchresult.template under
{foreach from=$searchresults item=result}
{assign var=article value=$result->getArticle()}
{/foreach}

please tell me how to do it, thanks a lot
chan15
 
Posts: 12
Joined: Mon Mar 24, 2008 7:24 am
LifeType Version: 1.0.6

Re: how to get the object I want in search result list

Postby markwu on Fri Apr 11, 2008 1:36 pm

I hope this is what you want.

{foreach from=$searchresults item=result}
{assign var=article value=$result->getArticle()}
{assign var="postOwner" value=$article ->getUserInfo()}
{$postOwner->getUsername()}

{/foreach}

Mark
markwu
Lifetype Expert
 
Posts: 920
Joined: Wed Mar 31, 2004 1:59 pm

Re: how to get the object I want in search result list

Postby chan15 on Fri Apr 11, 2008 8:22 pm

I tried this before, it does not work

Fatal error: Smarty error: [in makeit/searchresults.template line 10]: syntax error: invalid attribute name: '->getUserInfo()' (Smarty_Compiler.class.php, line 1547) in C:\wamp\www\makeit\blog\class\template\smarty\Smarty.class.php on line 1095

I think because {assign var="postOwner" value=$article ->getUserInfo()} need under foreach by posts
chan15
 
Posts: 12
Joined: Mon Mar 24, 2008 7:24 am
LifeType Version: 1.0.6

Re: how to get the object I want in search result list

Postby jondaley on Fri Apr 11, 2008 11:02 pm

remove the space in mark's post. It definitely should work, as it works on my blog: http://jon.limedaley.com/
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: how to get the object I want in search result list

Postby chan15 on Sat Apr 12, 2008 12:23 am

jondaley wrote:remove the space in mark's post. It definitely should work, as it works on my blog: http://jon.limedaley.com/


yup, it looks work on your blog, how did you do that? could you tell me specifically?
chan15
 
Posts: 12
Joined: Mon Mar 24, 2008 7:24 am
LifeType Version: 1.0.6

Re: how to get the object I want in search result list

Postby jondaley on Sat Apr 12, 2008 8:57 pm

I think it is the same as what Mark said.
http://jon.limedaley.com/plog/templates ... s.template
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: how to get the object I want in search result list

Postby chan15 on Sun Apr 13, 2008 1:16 am

yup, I did the same thing, but some weird error come out

Fatal error: Call to a member function getUserInfo() on a non-object in C:\wamp\www\blog\tmp\1\%%86^86E^86EDCE88%%searchresults.template.php on line 20

this is my blog address
http://chan.idv.tw:90/blog/index.php
you can search text in search field

and this is the file address
http://chan.idv.tw:90/blog/templates/bl ... s.template
chan15
 
Posts: 12
Joined: Mon Mar 24, 2008 7:24 am
LifeType Version: 1.0.6

Re: how to get the object I want in search result list

Postby jondaley on Sun Apr 13, 2008 8:51 am

You are using "$post" instead of "$article".
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: how to get the object I want in search result list

Postby chan15 on Sun Apr 13, 2008 11:08 am

everything is good now, thanks for all your kind help~ :)
chan15
 
Posts: 12
Joined: Mon Mar 24, 2008 7:24 am
LifeType Version: 1.0.6


Return to Templates

cron