We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14226
    • 8 Posts
    Hi,

    I’m attempting to add search to my site and found SimpleSearch.

    Is it possible to have each search result display differently depending which category it’s in? I want to have a picture icon to easily show which category the article is, and maybe change some colors with css.

    I also am curious how hard it would be to change the search to show a portion of the content with relevant text highlighted. I’ve created code for this in PHP before (for a simple AJAX search predictor), but I’m not sure how hard it would be to implement into SimpleSearch. Should I just dive right into the SimpleSearch code?


    I also have another question with regards to using conditionals in modx

    I currently have three article categories, each as its own (parent) resource. There are articles that are children of these. The default template for each article would be the parent’s template. It seems to me however, that the category resource would have a different template than the article resource.

    With the articles, you want info about the post, and comments. You wouldn’t want this for the category resources template as it’s just listing recent articles. This causes problems when someone creates a resource and doesn’t remember to set the template, causing the page to not have all the required information.

    Is there some sort of way to add conditionals to templates?

    ex. If it’s a child of resource 5, print relevant article info and add quip comments

    This would also be helpful for navigation to check what category the page is and change the link’s css class accordingly (ie. is the link already being viewed)

    Thanks in advance!