ModelAdmin filter resets itself - silverstripe

Is there a way to make ModelAdmin filters more persistent? Currently if you filter, edit a DataObject and come back, the filter is gone. Also prev/next from unclecheese/betterbuttons do not respect the filter. It jumps to the next Object but not necessarily one of the filtered Objects. I think there was a module for 2.4 called RemodelAdmin that did some of this, but since now all is GridFiled based, this seams like something completely different. Has anybody done some work in this direction for SilverStripe >3 or some hint how to achieve this?

I believe you should remove the module better buttons to get the filter to still be present upon selection of "back" or browser back action.

Related

Drupal 8 - How to display in a view all contents that were NOT created by the current logged in user

Pretty simple and quite frustrating.
I am unable to find an elegant solution for the problem problem stated in the title (really it's all in the title). If possible, I would like to add a simple filter criteria in the drupal interface.
I am new to preprocessed function and drupal, but I understand quite well how it works. It just seems quite messy to find the right variable...
it's all!
Thanks.
The way I would do it is by adding a contextual filter on Authored By of the content.
When configuring the contextual filter, under the "When the filter value is NOT available" -> Provide default value -> User ID from logged in user
You also have to exclude this in the more section, this will negate the condition.
This should solve your problem.

How can I store data to use it any where in my element

I am face to a problem and I can not find a solution!!! may not enougn experience with CakePHP :o)
I created a setting pages (Controller+Model+view)
On admin_edit action, I created a form to enter the parameter of the web site, as the site of name (to be display on the layout), the status (online or not), the id of the home page, ect.
I may be did it wrong but until I can not use variable on all element.
I tried Configure::write or Set('val',$val) but with both of them, I could not use it eighter on the layout or on a controller.
As I spent almost a day, I would like tp know if someone can provide me an exemple to create an array (or something else) to be able to use it's value, either on a layout, a controller, a view, an element or a compnent, or a Helper. But the main need, would be on a Controller, the layout and the view.
may thank for any tuto or exemples
P.
Your question indicates that you need to get a basic understanding of how CakePHP works.
To understand how a request is made, take a look at the picture in the section "CakePHP request cycle" in this link:
http://book.cakephp.org/2.0/en/cakephp-overview/understanding-model-view-controller.html
As you can see, Controller asks Model for data, then sets that data to the View. The View can never send data back to the Controller - that would be a new request.
To understand the use of layouts,elements and how to set variables in views, see the cookbooks description of Views:
http://book.cakephp.org/2.0/en/views.html
And of course follow the blog tutorial is a good thing to get a grip of the basic concepts.

How to show only populated menu tabs in Drupal?

In evaluating the Invite and Support modules for Drupal recently, we realized the default tab navigation is not the most user friendly. In particular, each module has a page of tabs that show the various categories of invitations or support tickets (pending, cancelled, etc). For developers, it's easiest to pre-define all the tabs, but from a user standpoint, it makes more sense to only be offered the tabs that contain content.
I assume it's possible to run queries to check which tabs should be displayed for a particular user and change the menus using hook_menu_alter. However, is that the best way to do it or will that cause problems with Drupal's menu caching? Is there a better way?
The answer by jhedstrom is correct, but I'm not that convinced that dynamically showing/hiding local tasks results in better UX, that sounds kinda confusing to me.
Instead, my suggestion would be to use a title callback (which can be added with the same hook_menu_alter() and show the number of things inside that specific tab. That is what I for example use for Privatemsg to show the number of unread messages.
See privatemsg_title_callback() for an example and hook_menu for more information about title callbacks in general.
If you want to selectively remove tabs in a dynamic way (eg, one node gets a tab, while another does not), you won't be able to use hook_menu_alter() because that only has an effect when the menu cache is being built. However, you can do this by overriding the menu access callback. If access to a tab is denied, it won't be displayed.
For example, to override a node tab, you might do something like this:
function mymodule_menu_alter(&$items) {
$item['node/%node/foo']['access callback'] = 'mymodule_override_access';
}
function mymodule_override_access($node) {
// Perform queries, logic, etc to determine if content exists at node/nid/foo.
// Return false if there is no content, otherwise fall through to the original
// access callback function.
}

Trouble with getting a sort to work within a view with views_bonus_pack

This is my first time using Views in Drupal and am finding that no matter what I do, I can't seem to get my output to sort on any field at all.
I'm using the views_bonus_pack to create xml output, but not sure if that matters.
I've tried the post date field, the node Id field, the node title field, and... the output is always the same.
Any ideas?
[Update, here are screenshots of what I'm working with]
http://emberapp.com/evanmcd/images/settings-2/sizes/m.png
http://emberapp.com/evanmcd/images/untitled/sizes/m.png
And, here's the resulting XML
http://www.mapendo.org/media_viewer/items.xml
Thanks to anyone who can help.
Evan
The sort criteria are listed to the right side.
Views screenshot http://img.skitch.com/20100715-jcfqnsu8mty6r7mexeyxsis4f4.png
If you changed the sort criteria trying to get differently sorted data without to obtain any difference, then there are just two possibilities:
The sort criteria are not used for feeds; it's rather improbable.
The style plugin module has an issue, and it's not working as it should.
If Views Bonus Pack is implementing a style, each style has its own settings that change the output produced by the style. When you click on the wheel close the style name, you would see some settings fields for that purpose.
Views style http://img.skitch.com/20100711-x3ag3ew6q33r3sje36qdnd4fti.jpg
Views style settings http://img.skitch.com/20100711-mfa6xnx3ca5261uxyq5w6j75g8.jpg

Is there a generic way to implement an ConfirmIfDirty feature for a web page?

On stackoverflow, and other websites, if you start making a change to form elements and then you try to navigate away from the page, you will get a confirmation message asking if you are sure you want to discard your changes.
This seems relatively easy to do by hand, but impractical to apply across an entire site. Is there any generic solution that can be plopped onto a page as a control (or even jQuery plugin) which will track IsDirty for all fields (without having to specify each field by hand)?
You can use the window.onbeforeunload event.
See also How can I override the OnBeforeUnload dialog and replace it with my own?
A possiblity would be to clone a selection of all your inputs when the page is loaded (and data into it as well).
You could then do a compare as desribed here:
http://chris-barr.com/entry/comparing_jquery_objects/
Word of warning though, this may be costly, performance wise.

Resources