Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By kidd1126 on
I'm useing drupal7 and views3x.
I build a views page, views module code is really complex for me.
So how can I disable and enable a views page programmatically?
Help ~~ Thank you
Comments
Why do you want to be able to
Why do you want to be able to enable/disable views programmaticaly?
What kind of view you are
What kind of view you are using ?
What ever type you create of a view...you can set the list of nodes, where you want that to appear or disappear. You can define content type etc..
If you have any specific need then explain and then only some body can help you...
Thanks,
RajeevK
Rajeev Kumar,
@drupler@bihar.social (ActivityPub)
Actually, now I am trying to
Actually, now I am trying to persuade my boss not to do that.
My boss ask me to make a backend interface which user (a man with no drupal or php skills) can manager the views.
Eg: We use views to build a news list page, we do two views page with different styles for the news list page.
So user can preview these two pages and set one enable. This must be done by my interface not views admin page.
No problem in that. If you
No problem in that.
If you are using Drupal6 then try Dashboard module. You can list the views list for every users & your user get to customize their own dashboard according to their choice.
I don't know this full fill your criteria or not, but sure it will help you if you see the structure of their organizing function.
You can some what functionality like this Drupal7 too.
Thanks,
RajeevK
Rajeev Kumar,
@drupler@bihar.social (ActivityPub)
Here is a snippet of code you
Here is a snippet of code you would put in mymodule.install
Disable views displays on update
If, like me, you're looking for a snippet showing how to disable a specific views display, then here's the solution I came up with. Just place this code snippet into your module install file
mymodule.install
and run the database updates.Hope this helps save you time. I've tested it out as a pattern in my own module and it has worked fine so far.
--
Madness takes its toll.
Please have exact change.
This one worked for me
Thanks! Elvis2's version worked perfectly for me.
Nice.
Thank you elvis2 this works like a charm for me too ;).