Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-15 11:43:10

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Can't get the search to do what I want

Firstly this is the first search I’ve constructed and I’m having a few problems.

I’ve got this code in my page:
<form action=”/search” method=“get” name=“search” id=“search”>
<input name=“q” size=“18”> <input type=“submit” value=“Search” class=“button”/>

and then this in the forms:
<h3><txp:permlink><txp:title /></txp:permlink></h3>

<p><search_result_url/></p>

When you type something into my search it brings up a range of results which are actual pages and individual articles and the search not very specific. Also it displays the article names.

I want it to display only full pages and the proper name of the page not the article name.

I’ve looked at few links such as justinfrench as well as a few others but can’t get the search to do what i want. What is the quickest and easiest solution for a newbie.

Last edited by gmorgan (2008-01-15 12:53:57)

Offline

#2 2008-01-15 16:35:36

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

Re: Can't get the search to do what I want

If you have articles that don’t exist as individual articles, but are only displayed as an article list (at least that is what I think you are referring to), you can change the search_results form so it doesn’t display the individual article URL but for instance the section page. I’m doing the same thing for a couple of my sections. So instead of <txp:permlink><txp:title /></txp:permlink> you could do something like this:

<txp:if_article_section name="some-section">
<txp:section title="1" link="1" />
</txp:if_article_section>

Offline

#3 2008-01-18 10:48:13

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

Hi thanks for your reply, I’ve tried this but its giving me no results at all now.

Offline

#4 2008-01-18 10:57:07

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

Got it working now I chnaged my code from
<h3><txp:permlink><txp:title /></txp:permlink></h3>

<p><search_result_url/></p>

to

<h3><txp:section title=“1” link=“1”/></txp:permlink></h3>

<p><search_result_url/></p>

and its now working, buts its not displaying everything

Last edited by gmorgan (2008-01-18 11:16:46)

Offline

#5 2008-01-18 14:34:29

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: Can't get the search to do what I want

I’m not sure why you are using the <txp:section /> tag. Could you not just have something like this in the form “search_results”:

<h3><txp:permlink><txp:title /></txp:permlink></h3>
<txp:excerpt />
<p><search_result_url /></p>

Keep in mind you can use both search results-specific tags (<search_result_url />) as well as normal article tags (<txp:title />). Now, when you say it’s not displaying “everything”, keep in mind the <txp:article /> tag defaults to only 10 results. So you may want to add the limit attribute to your search results page. For instance, you might have something like this in your search page:

<txp:if_search_results>
<txp:article form="search_results" limit="999" />
</txp:if_search_results>

Hopefully I am not muddying the waters.


Kevin
(graphicpush)

Offline

#6 2008-01-22 10:17:57

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

Hi thanks for everyones help, I’m now using
<h3><txp:permlink><txp:section title=“1” limit=“999”/></txp:permlink></h3>
<txp:excerpt />
<p><search_result_url /></p>

It kinda works but still is only displaying 10 results, its displaying all the section titles as i want but there are a few slips like ‘article’.

The first bit of code you provided only gives article results and the second doesnt work at all. Thanks for all your help.

Offline

#7 2008-01-22 16:17:30

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

Re: Can't get the search to do what I want

The section tag doesn’t accept a limit attribute, since that makes no sense. You apply that to the article tag.

Offline

#8 2008-01-31 15:06:05

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

something I forgot to say was that my images are not being displayed on some of the search result pages, its just got the ‘alt’ text. I think its becuase its displaying the full section and id and not just the section.

Last edited by gmorgan (2008-01-31 15:16:56)

Offline

#9 2008-01-31 17:11:52

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

Re: Can't get the search to do what I want

Where are your images, inside the articles or on the page? And which tags or code are you using to display them? If you are not using the TXP tags, it’s probably just a matter of adding a / before the image path.

Offline

#10 2008-02-05 11:51:20

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

yup I’ve left some / off the beginnings of my image paths, thanks ever so much. This forum rocks!

Offline

#11 2008-02-07 12:06:33

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

One last query, when you search for something, once you click on a page which is displayed from the search result none of the links will work on that page.

Offline

#12 2008-02-07 17:26:37

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

Re: Can't get the search to do what I want

We need more information :)
Do you mean that you click one of the search results, which takes you to the individual search result/article page, and on that page the links don’t work?
Can you give examples, what do the URLs that don’t exist look like?
And can you post the exact content of your search_results form?

Offline

#13 2008-02-11 09:56:53

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

My search box is on every page of the website so when you type something into it, and press search, it bring up the search results page, when you click on one of the displayed search results it bring up the page now when you click on a link on this page it just reloads the page over and over.

this is in the search form: <h3><txp:permlink><txp:section title=“1” limit=“999”/></txp:permlink></h3>
<txp:excerpt />
<p><search_result_url /></p>

Offline

#14 2008-02-11 17:32:34

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

Re: Can't get the search to do what I want

The limit="999" can’t be used in <txp:section />. It belongs in a <txp:article />tag.

My search box is on every page of the website so when you type something into it, and press search, it bring up the search results page, when you click on one of the displayed search results it bring up the page

So far so good, if I understand correctly?

now when you click on a link on this page it just reloads the page over and over.

This looks to me it has nothing to do with your search results setup. Can you post:

  1. the code on that page (the one that is being reloaded)
  2. the content of the article forms that are used in the article tag(s) on that page

Offline

#15 2008-02-12 10:00:47

gmorgan
Member
Registered: 2007-11-26
Posts: 42

Re: Can't get the search to do what I want

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><txp:page_title /></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="HAPedit 3.1">
<style type="text/css">
body{
	background-color: #FFF;
	background-image: url(images/background.gif);
	background-attachment: fixed;
}

div#nifty{
	background:#FFFFFF;
	margin-top: 15px;
	width: 731px;
	margin-right: auto;
	margin-left: auto;
	padding-right: 0px;
	padding-left: 0px;
}
</style>
<link rel="stylesheet" href="/css08/screenc.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="/css08/printc.css" type="text/css" media="print">	
<link rel="stylesheet" href="/css08/buildc.css" type="text/css" media="screen">
<link rel="stylesheet" type="text/css" href="/css08/niftyCorners.css">
<link rel="stylesheet" type="text/css" href="/css08/niftyPrint.css" media="print">
<link href="/css08/menu.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/css08/nifty.js"></script>
<script type="text/javascript" src="/css08/menu/menu.js"></script>
<script type="text/javascript">
window.onload=function(){
if(!NiftyCheck())
    return;
Rounded("div#nifty","top","#9FC3D8","#D1E5FF","border #C0C0C0","smooth");
Rounded("div#nifty","bottom","#A8C7DB","#FFFFFF","border #C0C0C0","smooth");
}
</script>

</head>
<body>
<div id="nifty">

<div class="container">
<div class="column span-24">

				<div class="header">

					<h1>name1; </h1>
					<h2>name2</h2>
					<p><a href="/"><img src="/images/mtcug_logo.gif" alt="mtcuog logo" width="101" height="105" class="glamlogo"></a></p>

					<form action="/search" method="get" name="search" id="search">
						<p><a href="cymraeg">Cymraeg</a> | <a href="accessibility">Accessibility</a><br />
						<input name="q" size="18"> <input type="submit" value="Search" class="button"/>
						</p>
</form>

  </div>

				 <div class="navi">

<script type='text/javascript' src='/css08/menu.js'></script>
<txp:article_custom id="428" form="home_ed"/>
<!-- Create Menu Settings: (Menu ID, Is Vertical, Show Timer, Hide Timer, On Click, Right to Left, Horizontal Subs, Flush Left) -->
<script type="text/javascript">qm_create(0,false,0,500,false,false,false,false);</script>


</div>


				<div class="bluebox">

				 	Home - Welcome</div>
</div>

	                <div class="column span-8 first border">

					<div class="promo">

						<txp:article_custom id="2" form="home_ed" />

					</div>


					</div>


	                <div class="column span-16 last">
					  <div class="promo">


							<txp:article_custom id="3" form="home_ed" />
					  </div>

	                </div>
						<hr>

					<div class="column span-8 first border">

					<div class="news">


					  <txp:article_custom id="5" form="home_ed" />
						  <br>
					      <br>
					  </p>

</div>
					</div>

	                <div class="column span-8 border">

						<br>

						<txp:article_custom id="4" form="home_ed" />

					</div>

<div class="column span-8 last">

<txp:article_custom id="8" form="home_ed" />



</div>
	<hr>
	        <div class="column span-24">
	          <div class="footer">

					<h5>name3</h5>
					<h5>name4</h5>
				  <h5>© name5</h5>
					<a href="quality"><img src="/images/qs_logo.gif" alt="qs logo" width="30" height="41" class="qslogo"></a>
					<a href="investors"><img src="/images/iip.gif" alt="iip logo" width="53" height="36" class="iiplogo"></a>
					<a href="positive"><img src="/images/pos_l.gif" alt="pos l logo" width="47" height="36" class="posllogo"></a>
					<a href="positive"><img src="/images/pos_r.gif" alt="pos r logo" width="45" height="36" class="posrlogo"></a>
					<a href="esf"><img src="/images/esf.gif" alt="esf logo" width="128" height="28" class="esflogo"></a></div>
</div>	
</body>
</div>
</body>
</html>

Here is the general format for my pages, (it keeps reloading everyone, referring back to my previous post)

Here is an home_ed article form: <txp:body />

Thanks for your help

(Edited for better display of code. -Els)

Last edited by els (2008-02-12 22:08:17)

Offline

Board footer

Powered by FluxBB