Combining data and form - drupal

I am writing a module in Drupal 7, that shows some data from database using theme('table').
It works great and now I would like to add some data filtering by a date and a category using
textfield and a select box.
How do I combine those two?

Your theme function returns the formatted output according to an array you pass as a parameter. So you have to filter the contents of your array before passing it to the theme function. Create your form elements using Drupal's FAPI, in the submit function of your form pass the parameters needed in your page's query string and use these values to filter/create your array before passing it to your theme function. Usually you use these parameters to filter your SQL query to the database itself.
As an example on how to implement this submission function: How to make a form self referencing in Drupal? Or any other options?
Also, check out Drupal's core search and dblog modules as references. The reports page in Database Logging has a filter and the Search module implements a search passing parameters.

Related

How to filter Analytics data in Data Studio with parameters?

I'm making a report in Data Studio using my Analytics data, and I'm having some trouble finding out how to filter it. Here is what I need to do:
I receive a "user" parameter in the URL, and I need to filter my "username" dimension with it. I want to make some kind of filter in the report, like Include usernameDimension = userParameter.
For some limitation in DataStudio, currently it is not possible to directly use Report URL parameters for filtering reports (when you create a filter, it only allows you to select fields, not parameters). However, it is possible to 'hack' this limitation with a new field that references the parameter.
Create a new boolean field called my_filter (or something you wish) with this expression:
field_i_want_to_filter = my_parameter
Then, just create a new filter in your report using this field, with the condition my_filter is true.
I can create a custom field to extract the username using a regular expressions.
Suppose you have a field called URL that contains something like:
https://example.com/path/path/endpoint?param1=blah&param2=bleh&username=Diego&param3=blih
You can use this formula in a new field to extract the username:
REGEXP_EXTRACT(URL, "[?&]username=([^&]*)")
You can easily add this custom field to a Drop down selector or something to allow filtering in your dashboard.

What is the syntax to add a column to the Custom Form list that shows where in WF it is used?

Super simple.
When viewing the list of Custom Forms in Setup, I want to add a column that shows where those Custom Forms are in use (or null if used nowhere).
This is similar in principle to viewing the list of fields, which has a list of forms on which those fields are used.
What is the syntax I can use to add the appropriate column(s) to the view?
As far as I know, there is no linkage in the backend that connects categories (custom forms) to their host objects. This is probably because the list could be massive and the query would take quite a while to execute as it would have to traverse every object in Workfront or each form would store every parent object ID.
Unfortunately, you can't even search for objects by associated category IDs, so if you wanted to build this yourself you would need to query each object and search its categories to see if your custom form appeared.

How to use Catalyst to search, select and display entries from my database

I have to use Catalyst in order to create a database and access it through a browser.
I have created a very simple database using DBIx-class and sqlite, just one table and filled it with some records.
I have managed to display the whole table and its rows using Template Toolkit view module and the code below into my controller.
$c->stash(ptm => [$c->model('DB::ptm')->all]);
Now I have created a simple search box in order to search the database and display any entries that match with the keyword, but I don't know how to pass the keyword to my controller nor how to implement the subroutine in order to achieve this.
I have searched for more than three days without finding any solution.
There are two completely different problems here.
Accepting arguments in Catalyst
Performing a search in DBIC
So, starting with the first one. Reading a query string.
$c->request->query_parameters->{field}
Then performing a search. Just call search instead of all and pass a hashref of your columns and values.
$c->model('DB::ptm')->search( { 'name' => $tag } );

form in wordpress that writes to many tables (with different columns)

Currently, I'm using tablepress to output different info using a table format. I want users to be able to add to existing information. I need a form in wordpress that saves user posts to these different tables. How should I go about this? Sorry if I sound stupid but I'm soft on html.
Thanks.
If you want to insert in posts table using custom form, you can use wp_insert_post().
This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. It takes an object as its argument and returns the post ID of the created post (or 0 if there is an error).
Reference : http://codex.wordpress.org/Function_Reference/wp_insert_post

Drupal 6 custom submit function to alter submitted node data

I have written a module that uses hook_form_alter to add a custom submit function to the node form. This function is not intended to remove the original node submit function, it is there simply to alter node data before it is inserted into the database.
The problem is that when I print_r the posted form array from inside my module when a node is added, the array is massive and it seems the posted data repeats numerous times. I need to know, which part(s) of this array I should be altering so that my altered values are inserted into the database.
To expand a little bit, the module works in the following way: My module attaches a custom submit function to the node form. A user submits a node (containing numerous CCK fields). Some of these fields are left empty. My custom submit function finds these fields and adds a value to them. The node is then inserted into the database.
The module and function I am using work perfectly, but I just can't seem to find what part of the submitted array needs to be altered so that the custom data will be inserted by the node module's own submit function. I would post the array but due to the size, it's probably not advisable, although if anyone would like it I could send it somehow.
Finally, I know there are easier ways of doing similar to what I am trying to achieve but unfortunately this is the only option in the circumstances.
Apologies for wasting anyone's time, I was looking at the $form array when in fact the submitted values are stored in $form_state['values'].

Resources