I am trying to create a Generic Search form (Controller) object. As in my website I have 4 different search forms, like
at Start Page I have a search form and on List page I have again a search form with more filters and on product page Have a search form with product specific property filters.
And what I want is that when user comes back from product page to list page, all the filters should a selected again automatically and if the user was on page 3 (pagination) the he should land again on page 3. Similarly from list to start, all the selected options should be populated again.
Is there any example available?
You could store this information in session variables.
For example, each time a list page is loaded, its number could be added to a $_SESSION["page_number"]; variable. Then whenever the list page loads again (being navigated from the product page for instance), the session value is used to retrieve the last viewed page. The form filters and other options could be stored in the same manner.
Related
I have replaced my entity with Blog to explain better.
I have the following route:
Route::get('/blog-category', 'BlogController#showBlogCategory')
which shows a form with a dropdown of different blog categories and some other input fields related to the category
The form POSTs to the following:
Route::post('/blog-details', 'BlogController#showBlogDetails')
Here I validate the request the form and return back if there is an invalid blog category or if it is missing
This method is called showBlogDetails because the category and the other fields are passed on to the next view return view('blog-details', compact('blogCategoryData'))
In this view there is a form to fill in the rest of the blog details.
Both the blogCategoryData (each data has a hidden input field) and the blog details are POSTed to the following route:
Route::post('/blog-store', 'BlogController#store')
This is also validated using a Request but if it fails it tries to go back, which it can't do as only POST is allowed to get there.
I need the blog category fields before I can show the blog details and a Blog cannot be created without either stuff so I can't temporarily create one either.
This flow of selecting/filling in blog category fields and then entering details is a requirement so has to be done in that order, in 2 different pages.
So currently it is:
GET -> POST (validate) -> POST (validate)
What is the best way around this or how would I make my current flow work?
one way is to use javascript and of course ajax to fetch blog data and show corresponding section. first the page only shows categories drop down box. after changing that to a correct category page makes an ajax request and fetches data. then replaces it in a hidden 'div' and shows it.
another way is to bring replace the categories box in the previous page.
I created some custom post types that include some advanced custom fields.
These are set up to include an event time, place — plus the guest of honor and his bio.
I'm packaging this all up into one post type so that the end user doesn't have to enter multiple posts — one for the bio, one for the event date, etc.
Most of the time, I want to show all the data about the event — time place, etc.
But sometimes I want to show only the bio of the guest.
So clicking link "a" will take you to a single post page which lists all of the information.
Clicking link "b" will take you to a DIFFERENT single post page which lists ONLY the bio.
I assume I would have to somehow create different templates which show this different data, or create a specific link which would direct to only the bio on its own page.
Any suggestions?
Layout of What I mean
If you need two links per post to serve different layout, than you probably need two separate posts. For controlling the layout you can use a custom field so for example you can have custom field "layout" which can be "brief" or "full". You can indicate value from the back end of the post and in single-event.php template, you need to check if the post meta is brief, than show brief layout html, else if it is "full" then serve full html. Is that what you are trying to do?
I've created a custom field (Checkboxes) in Wordpress > Users > Profile Fields. My site is an omni site for news, so it collects news from 20 different sources via RSS, and adds them ass posts in my Wordpress site. This is how my custom field looks like:
If you're only a visitor on my front page I'll show all posts on the startpage.
If you are a logged in user; then you should be able to select and save wich of the 20 sources you want to read in your startpage on my site. This is possible to select and save today, but only from BP User Settings page:
Now, the issue with the Users Profile Settings page is:
a) I do not want to have the form in the tab "Profile > Edit". I want my form on my startpage (above the news flow, for logged on users of course) and perhaps in a widget sometime - anyhow - the most important this is freedom to place (and style) the form wherever I want.
b) The form includes fields I want to remove (Name and Description, i.e. "sources" = field name) etc.
The user on the image above has selected and saved to read news from 2 different sources on my website. The code that handles this is on the startpage in my index.php is:
$sources = xprofile_get_field_data( 'sources', $current_user_id, $multi_format = 'array' );
query_posts(array('category__and'=>array($sources)));
Question
Is there a way of retrieving this form and update in from anywhere for logged in users?
I don't want to be bound to the idea of only having the form in the Profile Settings page. I want the user to have to form above my news flow on the startpage of my site, so the users gets the feeling of "Oh, I can customize my news flow if I create an account!" - and this should be done from anywhere for logged in users.
If I am getting it correctly, you want to display the form to logged in users. Have you tried
<?php if ( is_user_logged_in() ) { ... } ?> function?
you may also wish to update user fields with
update_user_meta()
I've been trying to find a solution to this, but haven't had a whole lot of luck.
I need to give the user control over which posts are being displayed on the homepage via selectboxes. Essentialy, a 'filter by' (list of categories) and a 'sort by' (date, name and a few other custom fields).
Is there anyway to do this and have the loop refresh dynamically?
Thanks!
Z
If you want a non-coding way to do it you could use the Types & Views plugin: http://wp-types.com/
Otherwise you'll need to use javascript or jQuery to trigger an update after the user selects the categories and other criteria. Something like a submit button that triggers an ajax post of the criteria selected which then retrieves the requested posts and updates the page content.
The joomla search results appear on the home page. I want it to show up on a new page. According to some online posts I had to modify the mod_search.php to set the item id to a non existing item so i set it to 0, but the problem is that the changes are not being reflected in my search module at all. I also tried putting a hidden field called itemid in the modules/mod_search/tmpl/default/default.php form but even that is not picked, I set the form target equal to _blank and tried to change the action page of the form to say index.php?Itemid=0 instead of index.php but all of this does not seem to reflect on the search module. When i manually change the itemid in the browser location box to 0, the results show up on a different page (thats what i want).
Please suggest what should I do?
Try to change request method of search form:
<form ... method="get">
<input type="hidden" name="itemId" value="0" />
or like this
<form action="...?itemId=0" method="post">
In Joomla 2.5 there is "itemId" field in mod_search properties, if set it to some non existent item than it clean ups search results page from modules which binding to some exact menu items(pages) and left only modules which are binding to "All" pages.
I know this is an older post, but I have found an easy solution for this for use with Joomla 1.6 and wanted to share it. It is a core hack, which isn't optimal because it will go away during upgrades, but it is easy to do.
What folks (like me) have been searching for is to allow a user to enter text in the search box on a page and have the results display in a blank page within the template, rather than have the results display within the same page along with other content, or be forced to use a menu item to send users to a separate search page.
When using a Search box within the Joomla! page to initiate a search, it is the 'component' portion -- not the 'module' -- of Search that is being used. There is a section in the Search Component Controller that either sets an ID for use with a menu, or automatically sets the result to come from and display in the requesting page. We just need to turn that off to send the search results to a blank page.
So, in /components/com_search/controller.php -- comment out the following code:
/* // set Itemid id for links from menu
$app = JFactory::getApplication();
$menu = $app->getMenu();
$items = $menu->getItems('link', 'index.php?option=com_search&view=search');
if(isset($items[0])) {
$post['Itemid'] = $items[0]->id;
} else if (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
$post['Itemid'] = JRequest::getInt('Itemid');
}
*/
This will display the search results within the content portion of a blank page of your template. At least it did for me.