Advanced search code for website


I am using portfolio server 10.2 and netpublish. long back in portfolio 7 I made a custom website which only has a drop-down keywords box for searching which has been fine until recently. Now I require to add a search capability like in the desktop portfolio “find”, using multiple ‘and/or’ lines. Would you please put the code here so I can paste it into my existing template.


Hi Neal,

Which template are you or will you be working with? The steps may be different, depending on the template.


My custom template is based on the template “Illumination.”


The ‘Illumination’ is no longer shipped as part of the NP Assistant (think this change occurred around v10 when lots of less used sets were dropped.

However, presuming you saved a custom master set, open that and you should find several variations for the search page on the ‘Search’ stage of the NP Assistant.

If you made your site by just editing the templates of an already published site, you are a bit stuck. Your best bet is to contact support and see if they can supply you a copy of the old Illustration master set (internally called ‘Site 10’).

If when you get new master, make sure you save a custom master set for your site.


Thanks for your reply.
I do have a copy of Illumination template. The problem is that none of the templates, past or present, offer the search capabilities that I want. Please look at the ctrl+f (FIND) screen in the Portfolio Desktop and click on “more choices”. I want that kind of option.


Your best bet would be to save a copy of the template using the Netpublish assistant. Once you have a copy, go into the saved template folder to the search pages:

On a Mac:

/Users/home/Documents/Portfolio/NetPublish/User Data/sites/web/sitename/pages/Search


C:\Documents and Settings\username\My Documents\Extensis\Portfolio\Netpublish\User Data\sites\web\sitename\pages\Search

Open the folder for the search page that you want to work with and open the search.npt file with a text editor. Look for the section that starts with:

and ends with:

This is where you can customize the search form that shows up on your site. Once you’re ready to test the customization, open the Netpublish assistant, select the copy of the template you saved earlier, then publish the copy of the site.

Hope that’s enough info to help you get the job done.


@Neal, actually NP can do this in part but you have to navigate around some glitches in the NP Assistant. NPA, for no explained reason, lets you select up to 5 search target fields - which get exported as separate input boxes on the search form. BUT, the glitch is NPA won’t let to select the same field more than once. To have, for example, 5 boxes targeting Keywords, you need to select Keywords and then any 4 other fields and publish; only once published can you then correct all the target fields in the output search.np. You’ll need to repeat the latter step each time you re-publish from scratch.

A separate issue is having the extra boxes appear and disappear. You’ll need to code that bit yourself, hiding/showing the extra inputs via JavaScript. Extensis don’t provide code for that. Regardless your first step should be the above to get a form with 5 inputs and then figure how you want to smarten up the UI.


Thanks, Mark. That advice is very useful and I will definitely try that. Unfortunately, I have no knowledge of JavaScript. Could you give me a sample of what I need, something I can just change the details to suit the specific needs?


It not just a single copy/paste and if you don’t understand JavaScript at all you probably need to employ someone to do this as implementation of this thing will doubtless involve lots of “but I just want it to…” tweaking.

Meanwhile, see this stackoverflow thread and see the first answer which includes a link to a worked example answer.


Is there a way to search on the search results in a Netpublish site?


I succeeded in creating 5 search dropdown boxes for finding keywords. The results default to “and”. How can I create a button by the side of each box which gives an “and/or” option?


You will need to hand code this as NP Asst can’t create that. It only offers inserting a ‘defaultjoin’ input with radio buttons that defaults to ‘0r’ (NPA doesn’t let you alter that default). The code comes from lines 312-320 of the dynamic_search.np library :

function Search_outputSearchOnForm() { if (this.needsFormValue && this.fields.length > 1) { Template.write(Strings.Global_94_SearchOn + '\n'); Template.write('<input type="radio" name="defaultjoin" value="or" Checked>' + Strings.Global_95_Any + '\n'); Template.write('<input type="radio" name="defaultjoin" value="and">' + Strings.Global_96_All + '<br>\n'); } }
It is called from NPT template code via:

Anything else requires you the hard-code the UI options in code in the NPT and/or NP files.


Thanks very much for your patience, knowledge and help.