Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-02-14 02:22:51

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

[txp:if_search]

OK – I can’t figure this out…

I want to use my default template to display 2 separate layouts depending upon if it is normal, or search results – so using

<txp:if_search> I have come up with the following – but it doesn’t seem to work for the search

Can anyone see anything out of the ordinary?

code<!— 1 —>
<txp:if_search>
<div id=“container-large”>
<txp:else />
<div id=“container”>
</txp:if_search>
<!— 1 —>

<div id=“inner”>
<div id=“header”></div>
<div id=“search”><txp:output_form form=“searchbar” /></div>
<div id=“navbar”><txp:output_form form=“nav” /></div>

<!— 2 —>
<txp:if_search>
<div id=“content-large”>
<txp:else />
<div id=“content”>
</txp:if_search>
<!— 2 —>

<!— 3 —>
<txp:if_search>

<h1>Search Results</h1>
<txp:article form=“search_results” />

<txp:else />

<txp:article_custom form=“single” id=“39” />
<h2>Latest News</h2>
<div class=“articlefdl”>&nbsp;</div>
<txp:article form=“news-article” section=“news” />

</txp:if_search>
<!— 3 —>
</div>

<!— 4 —>
<txp:if_search>

<txp:else />

<div id=“sidebar-b”>

</txp:if_search>

<!— 4 —>
</div>

<br clear=“all” />
<div id=“footer”><txp:output_form form=“footer” /></div>
</div>
</div>

Offline

#2 2007-02-14 03:04:22

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [txp:if_search]

Search uses the default section’s page by default. Are you sure you’ve placed this on the right page?

Offline

#3 2007-02-14 03:05:47

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: [txp:if_search]

Yes – this is on the default page: “You are editing page template default”

Offline

#4 2007-02-14 15:04:00

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [txp:if_search]

Are you using the ‘section’ attribute in <txp:search_input />?

Offline

#5 2007-02-14 21:50:49

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: [txp:if_search]

I’m using this for search input:

<txp:search_input label="Search" button="Go" size="8" />

And I have this custom form for the search input:

<form action="<txp:site_url />" method="get">Search: <input type="text" name="q" /><input type="submit" class="btn" value="Go" /></form>

Offline

#6 2007-02-14 22:31:15

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [txp:if_search]

What exactly do you mean with ‘it doesn’t work’? It doesn’t use the layout you specified for if_search, or it doesn’t display search results at all, or both?

Offline

#7 2007-02-14 22:55:56

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: [txp:if_search]

The search works fine and the results are displayed – but yes – it doesn’t seem to recognise the <txp:if_search> conditions and displays the wrong layout.

For example in the code below, I want <div id=“container-large”> to display if the search results are queried and <div id=“container”> to display if its the normal default page layout.

<!— 1 —> <txp:if_search> <div id=“container-large”> <txp:else /> <div id=“container”> </txp:if_search> <!— 1 —>

Offline

#8 2007-02-14 23:36:55

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [txp:if_search]

Strange, I can’t see anything wrong with your code… sorry for asking, but are you sure that #container-large in your CSS is not by accident exactly the same as #container?

Offline

#9 2007-02-14 23:43:16

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: [txp:if_search]

OK OK – drama over

Sorry guys – I just checked through all my settings and it seems I had set my default section to use another page (not intentionally).

Thanks for looking and sorry for wasting anyones time :)

Offline

Board footer

Powered by FluxBB