I want to have a single proximity filter that filters both articles and markers on the map in one hit.
At the moment users have to fill in two forms to keep the map in sync with the articles. This done by two separate views because I can't include fields and a map in the same view.
How can I include a geofield map and fields in one view and have both filtered by a single exposed form?
I can't include fields and a map in the same view.
This is not true, you can use Views Attachments display! So below a map you can have a group of other results such as a list, table etc with the same exposed filters, arguments etc.
Related
We have many "Configuration Entities" in our system. For example: list of banks, list of countries etc. Each list contain up to 100 items all from the same object model.
For example: Bank {account number, bank name, bank description}
We would like to build generic/dynamic editor that will contain:
grid view: a tabular view that show the list of items (add, edit, delete buttons) with pagination, sorting and search.
edit entity view: enable to edit the entity properties (with input validation).
We want to use it to edit all our different "Configuration Entities" with minimum work/boilerplate for adding new entities.
So I was thinking that we need entity descriptor (the entity properties, metadata and validation, rest API metadata, etc.) that will be the input for this module - then the module will be built dynamically.
Is there any already exists open source that I can use (in Vue or React) or should I build it from scratch?
I have to design a search form and display the results. I am having some difficulties finalizing the models/collections to be used.
I have a few fields which acts as filters. These fields are select boxes where multiple items can be selected. After an item has been selected from a field, I need to call the API which will return a list of results with this filter and also all the remaining filter options for the other fields based on the first filter.
What I am confused is how should I go about this. Should every select box be a model? Because the options for each select box will be changing.
About the results,
I am thinking that results should be a collection. But given that there is only one API endpoint here, I am confused which model should hold the url.
Since your API is actually returning a collection of results, I'd keep the filter parameters in a model, and while submitting search request, create the collection URL dynamically based on the filter model attributes.
You can go the other way, send the request from model itself, then in parse set results from response to the collection and remove it from model, but it seems more hacky than dynamically creating collection URL
I am using the data module to allow searching and filtering of table data. I am using views to display the data in a table with 3 exposed filters.
I want the user to select from specific values in 2 of the 3 filters. But I am currently only able to display a text box that allows the user to type a value.
You'll want to check out hook_views_pre_render(). Use it at first in conjunction with dpm() from the devel module to explore the view structure. Then you can directly alter the view (and its filters) before sending it on to be rendered. I would recommend using a php function, like array_unique(), or your own custom function, to loop through and uniquefy your results.
mymodule_views_pre_render(&$view) {
// make sure devel module is turned on first, then take this out when you're
// done exploring the view results
dpm($view);
// this part is pseudocode, I haven't memorized the view structure, but dpm() will
// show you what to actually put here
if( $view->name == "my_target_view_machine_name" ) {
// do your uniquefying here
}
}
When adding an exposed filter to a view, drupal gives you two options(Filter type expose): Single filter and Grouped filter, if you choose the Grouped filters, it will let you choose what type of widget do you want.(Radios/Select)
I have a page where it displays a filtered model instance list and allows users to update some fields of it or add new fields as a form.
I am curious what wpuld be a clever way of doing this, to delete and resave all the input data or make comparison for each data and save edited / new fields& entities.
I would like to mind you that I use postgres for saving these values and I display around 20 entries for this form.
The QuerySet object has the update() method - it's used in ie. Admin Panel for bulk updating multiple selected objects from change lists. Here is the method reference at django's official documentation.
How to use it:
Just create queryset with the models you want to update (assumng that MyModel has field named 'my_field'):
qs = MyModel.objects.all()
qs.update(my_field=value)
That's it - remember that update() method will not send any signals like the save() method - it will just run query directly to database.
As for 'adding fields via form' - I don't know if I got it right? You want to add additional related models or dynamically add fields to the model table on database?
If you want to add related models then use InlineFormset (http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-form) - it's quite easy to handle.
Otherwise you have to add fields to models' _meta as described here: How dynamic add custom field to model.
Using cakePHP my goal is to combine the index view of two or more controllers in one layout page.
Example:
I have controllers for: news, events, links.
I want to show the last five entries from each table in one layout page.
Also, when one of the links from the views is selected it should take the user to the respective view for that record.
I have read through the books section on views but don't see how making a view into an element would accomplish this.
What confuses me is how to combine from three separate controller/views into one layout?
Thanks
Create methods in your News, Event and Link models for fetching the last 5 records. Then in your controller either include the models in the Controller::uses property, or in the action use ClassRegistry::init() to get access to the model, e.g.
function my_action() {
$news = ClassRegistry::init('News')->getRecent();
$events = ClassRegistry::init('Event')->getRecent();
$links = ClassRegistry::init('Link')->getRecent();
$this->set(compact('news', 'events', 'links'));
}
You can then call these model methods from any controller action, keeping your application DRY.
In your my_action.ctp view, and indeed many other views, just render the elements e.g.
// my_action.ctp
<?php
echo $this->element('recent_news');
echo $this->element('recent_events');
echo $this->element('recent_links');
?>
Your elements can then just iterate over the $news (or whatever) variable displaying the items with links to the 'view' actions in their respective controllers.
Just because a controller matches a model, doesn't mean you can't use other models in it.
First I would say that views and controllers are not necessarily tied together -- Cake will implicitly add the view specified by the file heirarchy / naming convention, but this doesn't necessarily have to be the case. So try to think of the views as decoupled from the controller (which is one of the main purposes for using the MVC architecture).
Assuming your three views (A,B,C) are exactly how you want them copied, put them into an element (which is just a view file located in the special APP/views/elements/ directory). Now you can use them in either layouts or other views, just by making a call to $this->element( 'elementName', array( 'options' ) ).
Basically, just abstract the code you want to display into elements, then insert those elements into the desired layouts.
You can set up your controller to use the RequestHandler and then make your view elements capable of fetching their own data from separate controllers in your application.
This link explains it better than I can
http://bakery.cakephp.org/articles/view/creating-reusable-elements-with-requestaction
One thing to keep in mind is that the controller actions you are calling should account for caching their own data so you don't do unnecessary database queries.