drupal - Creating "ON/OFF News Links" functionality for a block created with View Module -


I'm a drum newbie, which needs some advice ...

I have a news story The list is on the block's homepage, with visual modules. Listening all these added news titles and links is cool till now. Now I have to add an on / off option in the admin side for the homepage news block. When the setting is on, it will work as it is. When it stops, only the title will not be linked to the news details page.

So, now where should I add it to the ON / OFF option? I have only added / edited / deleted pages for every news, there is no general news page to add such an option. Should I make an admin page with such an on / off option? Apart from this, I think that I need to create a DB table to keep it on / off position. And control this value on the home page block, if it is 1 or 0, and displaying the link according to the DB value: /

It looks a very long way

  1. Create a DB table
  2. Add php code to update db for admin options
  3. Get db value in homepage block to display link e.t.c .

Do I have any small, better way of not doing anything?

Appreciate a lot !!! Thanks a lot!

Of course you do not need to create a database tables for something like this. If you want a basic admin page, you have to write a simple module. First, follow this guide to establish a basic module. (Note: You do not need to add those database queries to your .ininstall file)

Once your module is enabled ...

1) your mynewmodule. In the module file, add a menu entry to tell to Drupal, where your administrator page can be accessed:

  function mynewmodule_menu () {Returns array ('admin / settings / mynewmodule' = > Array ('Title' => 'My New Module', 'Details' =>' Settings for News Display Parameters ',' Page callback '=>' drupal_tate 'form,' page order '=> array (' manewmule_admfarm '),' axis callback '=>' user_access ',' access logic '=> array (' site Administration of the configuration '),));); }  

2) Also add a function to create the form in the menu entry, in your mynewmodule.module file:

  function mynewmodule_admin_form () {$ Form = array (); $ Form ['mynewmodule-on-off-switch'] = array ('#type' => 'checkbox', '# title' => t ('enable news link'), '#description' => t ( 'Control that news items are related to stories),' #default_value '=> variable_get (' mynewmodule-on-off-switch ', 1),); Return system_settings_form ($ form); }  

3) Drupal Clear your cache to identify your admin page (you will have to clear any time to make changes to mynewmodule_menu ()). You can clear it here: Administrator / Settings / Display

4) Go to admin / settings / mynewmodule to see your admin form. The way this works, when you save the configuration, in a Duplicate database, the variable table will save a variable named "mynewmodule-on-off-switch" (in the same name as the array key). You can get this value anywhere by using variable_get ()


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -