It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I could not find a very proper title for my problem.
I have been trying to incorporate a beautiful search bar(http://loopj.com/jquery-tokeninput) in my drupal website. For this to happen I need to create a php callback function, that should be like: www.mysite.com/search/callback?q=var1.
This is a prerequisite and I cannot do otherwise. However, in drupal you set up the Urls in similar to www.mysite.com/search/callback/var1.
Is there a way to achieve the first one in Drupal?
Thanks :-)
EDIT-1:
What I have already done is :
$items['search/callback'] = array(
'title' => 'Search for String',
'description' => 'callback function for search bar',
'page callback' => 'search_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
)
I can recomend you to explore full example for jQuery UI Autocomplete taxonomy terms here: http://xandeadx.ru/blog/drupal/526. It's originally written in Russian but you can easily read code listings and download packed project. I think you can use the same idea of module.
Some notes:
You can't use q get param for your purpose because it is used by Drupal internally. In jQuery Tokeninput you can set another name of param with queryParam option.
I recommend to check any $_GET param with check_plain().
Related
I've recently upgraded a site to Drupal 7.59 with install profile:
Commerce Kickstart (commerce_kickstart-7.x-2.54)
Previously there was a function that had been added to the core which has now been removed because of the upgrade. This shouldn't have been added to the core and I'm not sure why it was. I've added this function back in and its not doing what it did previously so I'm not sure what other changes I would need to make to get it to work.
Here's the function which is found in /profiles/commerce_kickstart/themes/commerce_kickstart_admin/template.php -
function commerce_kickstart_admin_commerce_price_formatted_components($variables) {
// Add the CSS styling to the table.
drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
// Build table rows out of the components.
$rows = array();
foreach ($variables['components'] as $name => $component) {
$rows[] = array(
'data' => array(
array(
'data' => $component['title'],
'class' => array('component-title'),
),
array(
'data' => $component['formatted_price'],
'class' => array('component-total'),
),
),
'class' => array(drupal_html_class('component-type-' . $name)),
);
}
if($variables['components']['discount']['price']['amount']){
unset($rows[0]);
unset($rows[2]);
}else{
$rows = array_splice($rows, 2);
}
return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}
Can anyone give any pointers as to how to get this working? It doesn't appear to even be getting invoked.
Additional info from the comments:
it's a function in the profile?
yes
Was the function added afterwards (as in "Never hack core")?
Yes, looks like it.
Or was it removed by the maintainers?
Doesn't look like this was ever part of any official release
Do you use some version control system like Git?
Yes. This function was added on 14/05/2015 12:18 according to the repo.
Have you checked the profile's release notes and issue queue?
Had a look but don't see anything.
Thanks for adding the extra info!
Well, if this really was custom code than it should never have been added to the profile in the first place. Never ever add custom code to any core or contrib file. As it's going to be deleted as soon as you update. Like it has happened to you.
I guess the most important part of this custom function was drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css'); and that this commerce_price.theme.css maybe also got deleted.
Apart from that it's hard to tell from far and I'm not an expert in the commerce module. So, what I would do now is to narrow down the issue systematically.
Restore your repo to a time in history before this module got updated and get the site running.
Find out what this code is doing exactly, what other functions or flows are involved. Maybe with the help of the Devel module and the mighty dpm() function.
Try to rebuild the custom code from the profile in a custom module.
Then reset the repo to the current state and see if your custom module's code is still firing. If not, debug it to match the updated profile's code.
Apart from that, find the person who added the code and ask them why and what this code is doing. And tell them to never ever again hack core or contrib code :)
Good luck!
I am trying to figure out how can I create a chart similar to this one:
Such chart is to be created with any of the available Drupal modules for creating charts.
I am used to using the chart module, but I don't know how to implement this kind of charts with it.
Any ideas?
According to this Examples link, I think you should definitely be able to do it. If you still can't figure it out after reading that then let me know, and I can see where you are at.
I have managed to do it using Google chart tools module. I truly like this module more because it allows building interactive charts. My code can be found below:
function test_chart() {
$settings = array();
$settings['chart']['chartOne'] = array(
'header' => array('2004', '2005', '2006'),
'rows' => array(array('100', '500', '300') , array('900', '800','200')),
'columns' => array('Sales', 'Expenses'),
'chartType' => 'BarChart',
'containerId' => 'org_chart',
'options' => array(
'forceIFrame' => FALSE,
'title' => 'Bar Chart Test',
'width' => 550,
'height' => 250,
'vAxis' => array(title => 'Year',titleTextStyle=>array(color=>'red'))
)
);
//Draw it.
draw_chart($settings);
return '<p>Example org chart:</p><div id="org_chart" class="org_chart"></div>';
}
Please be aware that the answer with the examples link (for the Chart module) is no longer the recommended URL for finding the documentation about this module. While I'm at it, I add some related info here ...
There are indeed a lot of charts related modules these days that can be used for creating charts in Drupal.
The Chart module's project page contains some information that indicates it is "being depreciated and users are recommended to move over to the Charts module". Though most recently some comments in the chart issue queue contain some details that illustrate that that depreciation is being reconsidered. Refer to that issue queue for more details on that.
If needed, do not hesitate to create an issue in the module's issue queue. As an alternative create a new question on this site (or Drupal Answers) and find a way to let me know about it (eg via some comment in any of my questions or answers around here).
Be aware: I'm the maintainer of both modules Chart and Charts, and the author of the documentation of Comparison of charting modules mentioned in the beginning of my answer also.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using wordpress 3.5, I create a custom post type called order with title supports only.
Now i want that when this order will publish the title text will be order-#ID , (here ID will be the post ID that going to be publish) nothing else if user write something in title it will not publish it just save with value like order-#23 .
Another thing is any other way to hide title input (i don't wanna show title and editor) but save its value when it publish as like order-#265.
You could hook it at save_post and then update the database to reflect the change in title.
Note that I didn't test the code but it should be something like that:
function save_title( $post_id ){
global $wpdb;
$wpdb->update( $wpdb->posts, array( 'post_title' => 'order-#' . $post_id ), array( 'ID' => $post_id ) );
}
add_action( 'save_post', 'save_title');
as always after struggling my mind for 3 days with a problem i decide to ask for help here.
Im trying to create an advance search page with taxonomies and keyword field. You can see what i actually got in http://alianzasuperior.com/empleo/busqueda-avanzada/ ( dont panic, its spanish but just think as taxonomies and you will be ok)
The keyword part is working fine. I can also create taxonomies pages for example taxonomy-job_type.php to handle an individual taxonomy and it works aswell.
The problem is when i try to search in multiple taxonomies , and multiple terms for those taxomies. I tried to figure it out with scribu plugin "query multiple taxonomies" but im not able.
Someone did something similiar for what im trying to do?
Any help or clue will me much appreciate
Like you I am also digging in depth of wordpress multiple search,
check out my question in wordpress stackexchange, it might help you.
Till yet I also had no success in it.
https://wordpress.stackexchange.com/questions/27158/wordpress-multiple-category-search
like other times, after posting here i found my own question. Maybe its not the smarter solution but its working for me.
Im using the new tax_query as commented in http://www.wpmods.com/query-multiple-taxonomies-in-wp-3-1/
Basically if i get 2 taxonomies with two terms for example
$job_type='full-time+free-lancer';
$job_cat='designer+programmer';
I do the following:
$custom_query=false;
$myquery['tax_query'] = array( 'relation' => 'AND');
if ($_GET['job_type']){
$job_type=explode('+',$_GET['job_type']);
foreach ($job_type as $k => $name){
$job_types[]=$name;
}
array_push($myquery['tax_query'],array('taxonomy' => 'job_type','terms' =>$job_types,'field' => 'slug' ,'operator' => 'IN'));
$custom_query=true;
}
if ($_GET['job_cat']){
$job_cat=explode('+',$_GET['job_cat']);
foreach ($job_cat as $k => $name){
$job_cats[]=$name;
}
array_push($myquery['tax_query'],array('taxonomy' => 'job_cat','terms' => $job_cats,'field' => 'slug','operator' => 'IN'));
$custom_query=true;
}
And then if i got more than one term i use the custom query:
if($custom_query) query_posts($myquery);
If you want to mix it with keyword search just do:
$myquery['s']= $yourKeywordVar;
Hope that helps, I just discovered and so far my tests are working fine
EDIT: Seems like my "array-crawling" skills were not enough, thanks for the suggestions.
Moreover, I found out that I was checking the $discounttype condition with a plain "=" instead of a double "==". I guess banging your head on the same block of code for 3 hours makes you dumb and miss the most obvious errors.
First thing first, I'm on Drupal 6.
I have created a form with the following markup:
$form["cart_".$index] = array(
'#type' => 'image_button',
'#src'=> 'files/imghome/sidebar-add-demo.gif',
'#attributes' => array('rel' => '#item', 'class' => 'buybutton', 'title' => $discounttype),
'#prefix'=>'<p class="renewprop">'.$newren.' for '.$node_abb->field_tipo_abb_value.':</p><p class="renewblock"><span class="pricetag">'.$node_abb->field_prezzo_value.''.$discounttype.'</span>',
'#suffix' =>'</p>' ,
'#submit' =>array('usercp_form_submit'),
);
The form renders correctly, as you can see from this picture: http://cl.ly/3D2C2h1t1m2B351L1T31
(the N and R values beside the € symbol are actually the value of the $discounttype variable, just for checking it)
Each white box is basically an istance of the beforementioned form.
I need to pass the value of the $discounttype variable on each submit, so I decided to set it as the title of the submit button.
My problem is that in the submit function itself I cannot access the value of the 'title' attribute contained in the #attributes array. Mainly because probably I don't know the right syntax.
So far I've tried
$foo = $form_values['attributes']['title'];
$foo = $form_values['#attributes']['title'];
$foo = $form_values['attributes']['#title'];
And every other possible combination, but probably I'm just doing it wrong.
It's actually an hour that I'm crawling the web searching for an asnwer but I came up with anything.
first, you should mention form element ID.
so, you can access submit button by $form_state["cart_".$index]['#attributes']['title'];
but actually, why don't you use hidden field ('#type' => 'hidden') ?
I believe you have to use $form_state instead of $form_values. Give this a try:
$foo = $form_state['clicked_button']['#attributes']['title'];
I recommend using the Devel module while developing for Drupal. It is an extremely helpful tool during development, allowing you to see all the queries run when a page loads, stop a redirect to debug, and much more.