How to set up a search type using “range” fields Tutorial based on Seblod 2.3.9 and Joomla 2.5.6 This brief tutorial will help you understand the principle the construction of a « range search » using Seblod CCK. The range can be any searchable type (as far as i know) date, price… There are only a few pitfalls to avoid when you want to create such a type of search, so i'll give the complete procedure, emphasising these important points. 1 - Creation of an App Folder In the Seblod menu, choose App Folder. Create one to put your fields. In this example the name is « FolderTest ». It's optional, but you'll gain time when you search for them. 2 – Creation of the content type In the Seblod menu, choose Forms and Content types. Create a new content type, and choose FolderTest as template skeleton. Give a title to the form (here mycontenttype) and choose a folder to classify the content type. Choose FolderTest. Hit Save to save the content type structure. Then we need to create 2 fields : a title and a date field. What is important to understand here is the way you create the field : there's a lock on top of the Construction fieldset. It can be set on or off. When the lock is on, the fields you create next will be specific of the content type. It's called in Seblod : exclusive storage mode. When the lock is off, the field will be able to be used in other than this content type. Especially in our case when we want to use the data in the search type form. (non-exclusive storage mode). I strongly advise every reader to watch the videos in the tutorial section concerning the subject. http://www.seblod.com/network/videos/list-and-search/1676-storage-mastery-part-1.html http://vimeo.com/25745627 http://www.seblod.com/network/videos/list-and-search/1669-storage-mastery-part-2-exclusive-field-type-and-format.html http://vimeo.com/25736111 http://www.seblod.com/network/videos/list-and-search/1677-storage-mastery-general-field-type-part-3.html http://vimeo.com/25745502 The title field : Lock on (or off since in this tutorial i won't use this field in the search). The title is a basic text field, we save it in the FolderTest. For the database storage, we choose Standard > Article > title Information : Just for convenience, we choose title for the storage name, because it will then be saved as the default Joomla article title field. If we don't set that database storage field name, there will be a autogenerated name created for each article of this content type, based on the time. The date : Lock off. Then when you click on the + to create a new field type, it will then be non exclusive. We create the date field as shown in the image. The Title is mydate. The storage is : Standard > Article > mydate (same as the Name field). It's advised to click on the “Alter” checkbox to change the field format in the database, and then we choose the best matching format for our field (Datetime for the a date, int or decimal for a price...). This alter is only useful for the search part. 3 – Creation of the search type In the Seblod menu, choose Lists & search types Create a new search type, based on your content type (here mycontenttype) Set a title (here datesearch) and choose an App folder (FolderTest) Select the standard fields for any search : • CCK field (should be already selected) to match the content type (click on the square button 2 to check that the live value is mycontenttype) • A Joomla article field, mandatory for the search to work, we choose Article State, and we set the Variation (square button 1) on hidden. • A standard submit button. Then we have to create our « range » fields. Both will be created with the same parameters. Only the name will be different date_from and date_to). The date to start the range, we'll call it date_from. It will be a Calendar type. We set the absolutely same storage parameters than mydate, the field in the content type : Standard > Article > mydate, and we click on alter and choose the fieldformat (datetime here). Then, we add those fields in the search form We now click on button 3 on the right side (Match + Match Collection). In the “Match” dropdown we choose : • Future (or future only) for date_from • Past (or past only) for date_to This select is based on the content format : here we search for dates, so we chose amongst “date & time” options. If it were a range of price (or any numerical thing), we then would choose amongst “Numeric” options : (Lower, Lower only...) 4 – Create articles In the Joomla menu, choose Content > Article Manager Hover the New button and choose your content type (here mycontenttype) Create several article, with different dates. Here my articles are, as such : article 1 => 2012-06-01 article 2 => 2012-07-01 article 3 => 2012-08-01 article 4 => 2012-09-01 5 - Create a menu link In the Joomla menu, choose Menu > <Your menu> > Add new Menu Item Select List & Search from the Seblod menu items. Select the search Type in the right part in Required Settings. Save. 6 – Font End Click on the link created (here datesearch) Fill your form with a range of dates (from ->to) Your results are correctly filtered !
© Copyright 2020