Drupal 7 add fields to show in RSS feed for taxonomy - drupal-7

iam having troubles with RSS feed. I have found that I can get feed for specific taxonomy just adding /feed after that taxonomy, but how is possible to add/remove fields from that, where can I found this "view" for this feed?
Thank you

The callback is defined into hook_menu from taxonomy.module :
$items['taxonomy/term/%taxonomy_term/feed'] = array(
'title' => 'Taxonomy term',
'title callback' => 'taxonomy_term_title',
'title arguments' => array(2),
'page callback' => 'taxonomy_term_feed',
'page arguments' => array(2),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'taxonomy.pages.inc',
);
it call function taxonomy_term_feed
function taxonomy_term_feed($term) {
$channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
$channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
// Only display the description if we have a single term, to avoid clutter and confusion.
// HTML will be removed from feed description.
$channel['description'] = check_markup($term->description, $term->format, '', TRUE);
$nids = taxonomy_select_nodes($term->tid, FALSE, variable_get('feed_default_items', 10));
node_feed($nids, $channel);
}
it call function node_feed into node.module line 2575
So you can analyse those function to understand how it works and find solution

Related

URL hit showing output didn't want when I give permission to the module

On direct URL hit it showing the result I want not to done it but when I give permission to it it should be work fine. Help me regarding this I will be very grateful to you.
This is my module provide me the code for that module:
<?php
// $Id: person.module
/**
* implements hook_menu()
*/
function person_menu(){
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "perso_personal_info", // after visit drupal6/person, person_personal_info() function is called
'access callback' => true, // must return true, otherwise it will not visible as menu item
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
function perso_personal_info(){
$output = 'Name: Gaurav</br>';
$output .= 'City: nanital </br>';
$output .= 'Country: india </br>';
return $output;
}
function person_permission(){
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
); }
?>
Please provide me the the code needed; it should work fine when I set the permission for my module.
You need to update "access callback" in your hook_menu in which users permission will be checked as below:
/**
* implements hook_menu()
*/
function person_menu() {
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "demo_custom_personal_info", // after visit drupal6/person, person_personal_info() function is called
//'access callback' => true, // must return true, otherwise it will not visible as menu item
'access callback' => 'person_personal_info_check_access',
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
Now you will need to add below function in you module file (this function will check user's access permission which will assign from permission page)
/**
* To check user's permission
*/
function person_personal_info_check_access() {
if (user_access('administer my module')) {
return TRUE;
}
return FALSE;
}

drupal form field not loading correct data

I am building my first Drupal 7 module and am having trouble with the screen to edit a fieldable entity. I am using field_attach_form and it is working great for all accept one field which is displaying the field default rather than the current content of that field for that entity.
I have a text field, a number field, a number of Boolean fields and the one list_text field which is failing.
Any ideas what I a doing incorrectly? Code below is what I think is needed but please do let me know if you need more.
Code to create the field in hook_enable:
if (!field_info_field('field_available')) {
$field = array (
'field_name' => 'field_available',
'type' => 'list_text',
'settings' => array(
'allowed_values' => array('No', 'Provisionally', 'Yes'),
),
);
field_create_field($field);
Code to create the instance, also in hook_enable:
if (!field_info_instance('appointments_status', 'field_available', 'appointments_status')) {
$instance = array(
'field_name' => 'field_available',
'entity_type' => 'appointments_status',
'bundle' => 'appointments_status',
'label' => t('Available?'),
'required' => TRUE,
'default_value' => array(array('value' => 'No')),
'description' => t('Set to No if appointments with this status make this slot unavailable, Provisionally means that it will only reserve a space temporarily'),
);
field_create_instance($instance);
This entity has only the one bundle with the same name as the entity.
The code to create the URL in hook_menu:
$items['admin/appointments/appointments_statii/%/edit'] = array(
'title' => 'Edit appointment status',
'description' => 'Edit the parameters of the selected status code',
'page callback' => 'drupal_get_form',
'page arguments' => array('appointments_status_edit_form',3),
'access arguments' => array('access administration pages'),
'type' => MENU_CALLBACK,
);
The form function is:
function appointments_status_edit_form($form, &$form_state) {
// Get the status id from the form_state args
$status_id = $form_state['build_info']['args'][0];
// Load the chosen status entity
$status = entity_load_single('appointments_status', $status_id);
// Set up the fields for the form
field_attach_form('appointments_status', $status, $form, $form_state);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save changes',
'#weight' => 99,
);
return $form;
}
I have used the Devel module's dpm to check that the data is loaded correctly by entity_load_single and it is.
Thanks
Rory
I have answered my own question!
I was also programmatically loading some entities and was not loading this field with the numbers that a list_text field stores, instead I was loading the visual text.
I used a metadata wrapper and the code looked like this:
$w_appointments_status->$appointments_availability= 'Yes';
I changed it to:
$w_appointments_status->$appointments_availability = 2;
In this example 'Yes' was the third allowed value - hence 2.
So the code in my question was in fact correct although I have since added 'widget' and 'formatter' parameters to the instance.
I am sorry if this got some of you scratching your heads thinking ' but that code is correct'!!
Regards
Rory

Is there any way to define a new route in druapl 7 which start with wildcard

I implement a hook_menu and I want define a route like this
$item['%'] = array();
and when user enter url like this domain/whatever the word whatever must pass as an argument to page callback function. can any body help me please.
There is no way to have a fully dynamic route in Drupal, most modules (including core) loop on content_type to create these kind of routes
foreach (entity_get_info() as $entity_type => $entity_info) {
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
$path = $bundle_info['admin']['path'];
$items["$path/fields"] = array(
'title' => 'Manage fields',
'page callback' => 'drupal_get_form',
'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'field_ui.admin.inc',
);
}
}
Example at http://cgit.drupalcode.org/drupal/tree/modules/field_ui/field_ui.module?h=7.x#n79

Get Image path in drupal

may be this question has been asked earlier but i have not found an appropriate answer for this. I have image uri path and i want to create a web services in drupal. From android when i call this webservices i will send the uri then i want to get the image url that will return me my custom image style url. But when i am passing the url with file extension giving me Could not find the Controller
This is my function that will return the url of the image:
'image_url' => array('operations' => array('retrieve' => array(
'help' => t('The resource to retrive the image of the given url/uri.'),
'callback' => '_fieldinsync_image_url_retrieve',
'args' => array(
array(
'name' => 'url',
'optional' => FALSE,
'source' => array('path' => 'url'),
'type' => 'string',
'description' => 'The url/uri of the image.',
)),
'access callback' => 'services_access_menu',
),),),
Function:
function _fieldinsync_image_url_retrieve($imgUrl){
$value;
$value[]=array(
'vname'=> 'session_id',
'sname' => 'session_name');
$value['uri'] = image_style_url('mobile_product_image', $imgUrl);
return $value;
}
Uri is :public://Tab - A2107.jpg
got my Answer
needs to add these lines in settings.php
$conf['image_allow_insecure_derivatives'] = TRUE;

Drupal allowed_values_function does not get called when creating a field

For some reason my allowed_values_function never gets called when showing a field on a user bundle. Code:
function get_business_units()
{
$options = entity_load('business_unit', FALSE, NULL, FALSE);
$opt = bu_to_list_values($options);
return $opt;
}
function MYMODULE_enable()
{
if (!field_info_field('field_user_business_unit')) {
$field = array(
'field_name' => 'field_user_business_unit',
'type' => 'text',
'settings' => array(
'allowed_values' => array(),
'allowed_values_function' => 'get_business_units',
)
);
field_create_field($field);
// Create the instance on the bundle.
$instance = array(
'field_name' => 'field_user_business_unit',
'entity_type' => 'user',
'label' => 'Business Unit',
'bundle' => 'user',
'required' => FALSE,
'settings' => array(
'user_register_form' => 1,
),
'widget' => array(
'type' => 'options_select',
),
);
field_create_instance($instance);
}
}
The field is created, and even displayed on the users "edit" page when editing their info. But the only value is "Select" or "None". My method is never called (I even placed a debug point). This is all in MYMODULE.install file.
The problem is: 'type' => 'text'.
You have to use: 'type' => 'list_text'.
Allowed values is meaningless for a text type.
Your get_business_units() function needs to be in the MYMODULE.module file; the .install files aren't included in a normal Drupal bootstrap.
Have you tried
drush features-revert MYMODULE ?

Resources