The main strategy of this book is to use only out-of-the-box, user contributed modules. It is going to be an exploration of modules and their features. And I go even further, by looking at how to structure content and making a few €, $, ¥, ¢, £. In this book, I will guide the reader through the different modules needed to build a solid community site. For about 8 years now, Drupal has been providing users with one of the best and most versatile frameworks around. In fact, it has just won (for the second time) the Best Overall 2008 Open Source CMS Award and Best PHP Open Source CMS Award. Drupal is one of the best content management systems (CMS) around. A number of popular topics, such as profiles, picture and video galleries, maps, messaging, groups, friends etc will be discussed. More than 100 screenshots will guide the reader through the process of setting up a social networking site with the Drupal 5 or 6 framework. If that is the case, you may do something like this: cache_clear_all( 'view_machine_name'. Sometimes after changing views, you may want to clear views cache. Please note you can only delete views, which have been created without Views hooks, for example through Views admin panel or using the clone method I mentioned above. $view = views_get_view( 'view_machine_name') Delete a viewįinally, I would like to show you how to delete views programmatically. I prefer xdebug and/or devel print functions, such as kpr(), dpm(), etc. Just remember to use right tools for debugging. My code examples are supposed to give you ideas how to proceed further. I did not have a goal to explain everything. Similar way using get_option() and set_option() methods you may change view footer, header, filters and some other settings. $view->display_handler-> set_option( 'sorts', $sorts) Replace existing sorting criteria with our changed criteria. $sorts = $view->display_handler-> get_option( 'sorts') I am going to change the sort order for this criterion to Ascending. The typical sorting criterion for page display of any node view is the node publication date (Content: Post date). Now let us try to change sorting criteria. $view->display_handler-> set_option( 'path', 'your/path') Īfter running this snippet, your view should become available at http//yoursite/your/path Edit complex settings of a view display $view->display_handler-> set_option( 'title', 'New title') I don't use t() because I don't need it in this context. Initialize view handlers to be able to adjust them later. Okay, let us change the title and the path of the Page view display. The display can be either a block, a page or whatever else Drupal provides.įor your convenience, I will work with the Page display because it is the most popular one. If a view itself is the sort of a container for some data, then a view display is the data representation. Edit trivial settings of a view displayĪny view usually has displays. Put this simple code into your module and replace the view_machine_name with the machine name of your source view. Clone an existing viewĬloning views is easier than you could imagine. Let us get started from the simplest task. However, I suppose that the main principles and approaches are still valid and somehow applicable for Backdrop and even Drupal 8 because I don't think they have already changed the Views architecture significantly. There is plenty of articles about Views hooks on the net, but this one is not about the hooks. Now I am going to share the results of my research. To create a custom presentation management dashboard I have learned how to clone, edit and delete views in Drupal 7 programmatically.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |