Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support passing searchterms
Seeker_of_truth
Posted on 21 Sep 2010, 09:53:59

Access: Member
Total Posts: 10
Joined: 2010-09-21



Ive been trying to use an include on page to return as specific set of articles [about MUSIC].


<?php
$template = "3.6 Ajax Template";
$search = true;
include './news/index.php?searchterm=music';
?>


is there a way to pass the search term ?

#2867
Last edited by Seeker_of_truth at 2010-09-21 17:25:54 Reason:
Chris
Posted on 21 Sep 2010, 11:54:41

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

This is where categories come in useful, when posting your news articles if you assign them to a certain category then you can selectively choose which articles to show on your site by specifying the category before the include code, something like this

Code:
<?php
$cat
[] = "Music";
include 
'news/index.php';
?>
#2868
Seeker_of_truth
Posted on 21 Sep 2010, 14:07:05

Access: Member
Total Posts: 10
Joined: 2010-09-21


I was hoping to return any articles across any of my categories, that contain the word 'music'

I thought it looked possible to use the search feature for this. As long as I could pass the required searchterm MUSIC. Like


<?php
$template = "3.6 Ajax Template";
$search = true;
include './news/index.php?searchterm=music';
?>


I though it could be like calling a 'hidden' field in a form action.
OR to append the searchterm on to the URL.
#2870
Seeker_of_truth
Posted on 24 Sep 2010, 09:22:55

Access: Member
Total Posts: 10
Joined: 2010-09-21

Can anybody point me in the right direction for this ?

I have categories like Books, DVD's, West-end shows etc and wish to pick out any articles in the categories that mention MUSIC.

I thought I could do tbis with the search tool but so far no success.
#2872
Chris
Posted on 25 Sep 2010, 00:21:54

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

One way to do this would be to slightly modify the built in search function. When you specify $search = true, before a news include, it shows the search form. You could edit this form and change it so that instead of checking if the form has been submitted, it checks if a search term has been specified, if so perform a normal search.

If you edit functions.php, on line 161~ change this

Code:
global $searchform, $searchresults, $catcutoff;


To this

Code:
global $searchform, $searchresults, $catcutoff, $searchquery;


Then a few lines down you should see 2 instances of $_POST['searchsubmit'], change both of these to $searchquery and save.

Now if you do a include something like this

Code:
<?php
$search 
= true;
$searchterm = 'something';

include 
'news/index.php';
?>


It should give you some search results based on the $searchterm variable.

This isn't ideal as it formats each result depending on how "Search Results" section within your template is formatted.

In a future version of the script I plan on changing how search works, instead of it returning results based on the "Search Results" template, it'll return them formatted how your news is normally formatted when simply displaying it, so basically when searching for news it'll display exactly like it normally does.
#2873
Seeker_of_truth
Posted on 25 Sep 2010, 09:46:53

Access: Member
Total Posts: 10
Joined: 2010-09-21

There are actually four POST['searchsubmit']

$_POST['searchsubmit'] = (empty($_POST['searchsubmit'])) ? '' : $_POST['searchsubmit'];
$_POST['searchstring'] = (empty($_POST['searchstring'])) ? '' : $_POST['searchstring'];

// if the search form hasn't been submitted hide the search results section
if(!$_POST['searchsubmit']){



should all four be changed ? [i tried that and it didnt work].
After the change, will the search function still continue working in its normally way [offering a search box ] ?
#2875
Last edited by Seeker_of_truth at 2010-09-25 22:11:28 Reason:
Seeker_of_truth
Posted on 30 Sep 2010, 20:22:00

Access: Member
Total Posts: 10
Joined: 2010-09-21

Chris

Can you clarify this.
There are four instances of $_POST['searchsubmit']
#2896
Network-13.com © 2013