I Am new to drupal I need to customize core functionality like register module and event module.please share you thought / sample code / sample website for get the clarification over my issue
Thanks in advance
Balaji
From what you posted in the comment to creejayoz answer, it seems like what you are after is not using hook_form_alter, but something in the line of what the profile module does. It's part of drupal core, and with it you can add extra fields to the user like first and last name. There are also more advanced modules that you can use instead, but it seems like you wont need it. Using the profile module will also be a lot quicker and easier than using hook_form_alter as you wont need to create a db table make SQL and such to the save the data.
You can use hook_form_alter to heavily modify the way Drupal's registration works, by modifying the form's fields, adding extra validation/submit functions, etc. It's difficult to give more detail without knowing what you're wanting to do.
Related
I have a specific theme which I apply to my html and now instead of editing it everything I create view. I want to edit the html helper methods and all all my necessary classes and id information can be put in one place.
How do i do this?
Do I just create a new custom one or is it easier to edit one that is already there? I do plan to add some ones that are not there.
I have googled abit but all the answerers I found give specific code to their problem. I dont even know which folder to put my classes in? In a book im reading about mvc it explains custom model template, but i dont think that is exactly what im looking for?
Even a basic example will be great.
Do I just create a new custom one or is it easier to edit one that is
already there? I do plan to add some ones that are not there.
I would say creating a custom one would be fast and simple. But if you still want to give a try by enhancing existing one, than you can get the source code of System.Web.Mvc for CodePlex, and make your necessary modifications and build it, reference it and use it in your project.
I’ve a question about Hooks. Being kind of new to Drupal I haven’t had much experience with hooks but a friend of mine suggested to get familiar with it and learn it to solve one of my problems on my site.
The thing is, that I have a module fbconnect which I use for users to connect via Facebook and use their profile picture at Facebook, on my site.
Everything is working, I’ve two checkboxes which and the connection and profile images works quite well but the problem is that above the two checkboxes I want a descriptive text to appear.
The only way I so far have to put in this text is to create a “description” field to the first checkbox. Unfortunately, it chooses to display this text beneath the checkbox so now it look kind of strange with a checkbox, a 3-4 lines descriptive text to the entire Facebook function, and then another checkbox.
If hooks are the right way to go to solve this problem, how do I actually do it and where do I actually insert the hook? I can imagine that it is the hook_form_alter function I need to have and in my fbconnect module the function fbconnect_form_alter exists but where I go from here I really have no idea.
I’ve tried to read up and see some instruction videos about hooks but I’m still puzzled about this apparently very nice feature in Drupal.
I'm using Drupal 6 for this site.
Any help or advice would be very much appreciated.
It sounds like you might also need to look at the Theme system in Drupal. In particular, take a look at theme_checkbox. From glancing at the code, there seems to be a label that is rendered after the actual checkbox. In your custom theme function or theme file you can try changing the order of the two.
In drupal, a "hook" is the way to interact with some piece of code.
In you have a hook_bar() hook, and is your module named 'foo' implements foo_bar(), then this function is executed.
In your case, you'll need to create a module, and impletements hook_form_alter()
You can find a tutorial there that show you how to add a checkbox. If you need to add some text, you can use the same method, except instead of adding a checkbox, of course, you just add a textfield
Here is an awesome beginner's video about adding custom hooks with the example of hook_form_alter from Drupalcon Chicago 2011 which is perfect for this situation and will hopefully help you in this. As a newbie to Drupal it surely helped me and I would highly recommend watching other videos. Thanks to the drupal community for posting these.
http://chicago2011.drupal.org/sessions/introduction-module-development
I use CCK in Drupal 6 and I need to build a search form in Drupal with 8-10 fields used as a filter. When the user submits the form I need to make a query on the DB applying filters and presenting the result on a table.
I know how to do this programmatically by building dynamically the SQL-where condition (joining node and content_type_xyz tables) but I would be interested in learning how to do it in the "Drupal way". I think I would have to use Views and Panels but I don't know if they can be easily implemented in situations like this. I've tried to build some sample views but I think to be faster in creating code by hand.
If you want custom searches you need IMO to do 2 things:
Hook yourself into _search so you can use Drupal's display for the results. Inside this form, you can create your queries for the database or load other content as you wish, just be sure to use pager_query.
Extend the search form that already exists or built your own. I suggest buliding your own. use what is already existing from Drupals search form. This way, you have a clean way of how to do this.
There is actually no need to use any fancy modules (that doesn't mean you should rule them out, but a search is something so esential that it is quite well handled with the basics).
Using the above, you'll get a native search form with all it's power and can make use of global paging options.
If you do it using views you will only be limited to the filtering you can do using SQL. Views is an SQL builder, and does not contain any 'proper' search functions. That said, it sounds like Views will do what you want; if you create filters under views and then click 'Expose this filter', you will suddenly see fields that allow the user to enter something to filter by appear.
I need to create a new filter for my view inside php snippet. Is it possible to do that using Drupal API? Can you also give me code example if possible?
Thank You,
Toliy
Your comment made much more sense ;)
What you are asking for is easily possible with Views out-of-the-box. Specifically, when you are in Views, lookk for the section called "Views arguments". To get you started there is a massive tutorial on drupal.org about them.
The path to your page will be something like:
movies/year/%
The character '%' signifies an argument
Is there a module that allows me to log all the searches made on a view ?
Thanks !
I think you will need to write custom code to achieve that! I'm assuming you know some basics about writing Drupal custom code. You will need to use a hook that gets called before your view is displayed. In the hook you should log whatever information you want e.g. the keyword that was entered in the exposed filter.
Please see http://drupalcontrib.org/api/group/views_hooks/6 for the hooks that are available to you in Views.
I'm guessing you would probably use something like hook_views_pre_render