CodeIgniter Persistent URL attach with every URL - codeigniter

In CI, I want to attach selected filter (in $_GET method)
to appear for every link I click.
This filter are persistent so is this filters selected in any page should be available for any other page in project.
For example, I selected dealerID, GroupId in one page, let's say dealer in page www.domain.com/dealers?dealerId=2&groupId=10 page, then if I click this another link named *www.domain.com/group*s the groups page should look like www.domain.com/groups?dealerId=2&groupId=10 that was selected in previous page.
And one more thing: I am using a main controller that will be inherited by all controllers for some reason.
Any help would be appreciated.

You could have one universal $data['filter'] variable that is going to preserve all variables that you need for filtering and than in view just add $filter at the end where you need it.
$data['filter'] can be collected/generated in constructor and defined by default.
It's little bit tricky solution i would rather use session to keep data of that kind and having "reset" button on page.

Related

Oracle APEX takes a value from a function and uses it to open a new page

I have a function that returns a value (e.g.27).
I am put this value to my page item (P2120_SYMPTOM_ID) and i want with this value to open with button another page (P2140).
I am going to button Link builder - target and i am using P2120_SYMPTOM_ID like this:
but unfortunatendly this value doesn't pass to my new page criteria.
How can i use this value?
If you're just navigating to another page (as opposed to opening a modal window) then use action "Submit" on your button and create a branch to the new page. That is how navigation is supposed to be done. The link builder links are generated when the page is rendered and do not pick up session values.
This is a common question, and relates to the fact the link uses values during page render, not what may have happened during interaction with the page
A common solution is presented in the Oracle forums here
https://community.oracle.com/tech/developers/discussion/3725149/pass-client-side-state-to-modal-dialog
Alternatively, there is a free & supported FOEX Redirect plugin that also solves this problem
https://fos.world/ords/f?p=10000:1080

How do I point a menu item to a component's task?

How do I point a Joomla menu item to a specific task in my custom component? I have had no trouble creating menu items that point to my views, and each view is available in the list when I select my component in the menu. But I have not found a way to route the menu to one of my component's tasks.
In some cases, I am using a controller method (i.e. a task) to decide which models and views to present to the user. Usually this is when I need to display data from multiple models, or I need to use information in the session state to determine which view is appropriate for the user. It is in these cases that I need a menu item that points to the task.
So, how do I get a menu item to bring a user to "index.php?option=com_mycomponent&task=do.something"?
What have I tried already, you ask? I've looked at just about every Google reference I could find, and none seem to address this issue. I'm either looking for the wrong thing, or it's so dead easy that nobody has ever had to ask for help. I have also looked through the Joomla components & menu items, finding no examples of a menu item pointing to a controller task.
You can add a field to the request fieldset. Name it task. The value would be "do.something". Make the field type="hidden".
I'm suggesting the hidden because you really don't want the users to be able to change it.
The request fieldset is for fields that go into the url directly with the format &name=value.
I found the above answer not flexible enough and finally found this to work perfectly, you can override the menu item form xml ( administrator/components/com_menus/models/forms/item.xml ) and make the link field editable so you can add any request parameters you want, including tasks.
Make sure you leave/add the view name of the request as otherwise the link type cannot be determined, so add it even if it is not relevant eg. &view=yourview.
See system plugin onContentPrepareForm below
function onContentPrepareForm(&$form, $data) {
$option = JFactory::getApplication()->input->get('option');
// allow us to edit the link field of the menu item for this component to include some custom request values
if($option == 'com_menus' && $data->type=='component' && $data->request['option']=='com_your_component_name'){
$form->setFieldAttribute('link','readonly','false');
}
}

Joomla 3.2 - Load Component View from Specific Menu Item ID inside Another Component

I'm trying to get my head around Joomla 3.2's new framework and develop a capability/feature in a custom component (lets call it com_custom) that can load com_content's category blog view within com_custom's view, using the category blog's menu item id!
There are quite a few codes that I saw here and around the web that only load the default view of the 'imported' component, rather than the view specified in the imported component's assigned menu parameters. Also, most of these codes use deprecated functions, so I'm quite lost now.
So what I need to be able to add is:
Include a category blog view (say from menu item id 223) within com_custom's current view.
It should import all of the parameter setting of the category blog's menu item.
It should not be in an iFrame
Any help is much appreciated!!!
You can't include com_content because it makes use of the JPATH_COMPONENT constant in 14 different places, most notably in content.php (the main file that's loaded, even before the controller) and in most views, in order to load helpers.
These are the first two ways that come to mind to overcome this limitation:
Instantiate the articles model, load the data, and use your view to display it; you'll need to dig into the menu table to find the params related to your menuid; Bewre: Search engines might consider the duplicate content as spam.
Insert a jquery ajax call to get the url of the menuid adding &tmpl=component i.e.
index.php?option=com_content&view=category&id=13&Itemid=522&tmpl=component
The latter will be much easier to implement. Search Engines will NOT see the different content under different urls, since it's ajax.
Regarding the limitation, see also this question:
Joomla how can i create model from other component

MVC3 global predicate filter

I am building an admin console and all controllers depend on a dropdown selection for customer.
I would like to move this customer selection to the layout and persist it across all controllers so that you do not need to select it everywhere.
What is the best way to go about doing this?
Thanks in advance.
Move the dropdown to your _layout.cshtml.
Create a BaseView that all views will inherit from and give it a property to store the Customers & Current Customer.
Create a BaseController method that will fill in a BaseView instance.
Store the currently selected customer on your session.
Create a Global Filter and have it check all views to see if they inherit BaseView. If they do it can convert them to a BaseView and then fill in the properties.
Write some code in the _layout that can use the View to fill in the dropdown. I'm a bit fuzzy here since my coworker actually did this part when we did something similar.
When the user changes the dropdown value you can use JSON to call an action method that will update the current customer in session.
I would consider writing HTML helper. You assume that all the birds can fly, but say one day you have another exceptional scenario and you no longer need this dropdown box. Alternatively include it in a partial view and render that view where you need it - it's only one extra line of code.
E.g.
#section main_content{
#{ Html.RenderPartial("MyPartialViewContainingDropDownBox"); }
}

jsp dynamic gui

i am asking myself if it is possible to somehow create a dynamic gui in jsp. So that i could have something like a dropdown menue for the country and based on what i have selected in that window a dropdown menue for cities, without reloading the jsp page. Or, in a dialog with multiple input lines, to be able to add an additional line with a button, again without reloading the whole page. In the first case the cities information would be in a database, in the second the information provided would be stored at the end in a database, so i cant just use java script (and don't really want to).
At a minimum, you would need to utilize JavaScript to implement what you want. Most would implement it the way Tim describes in his first paragraph.
Set up two .JSP's:
The first contains your main form with the country drop-down menu. Some JavaScript on the first .JSP triggers an AJAX request to a second .JSP. The second .JSP accepts a country-ID parameter and uses a servlet to query your DB for a list of cities, then renders that data. Once the request returns, the JavaScript in your first .JSP inserts the list of cities into a new drop-down menu.
This may seem complex, but several JavaScript libraries exist to assist you with this task. Look into jQuery or Dojo.
To update the page without posting back the whole page, the browser would use ajax. Using a database does not eliminate ajax. Ajax calls server code that digs your data out of the database.
Regardless, to do what you want, without writing your own javascript, look at GWT (Google Web Toolkit). You right ajax applications in Java that generates the javascript for you.

Resources