how to change drupal 7 cck body title in form alter
for eg:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == "mymodule_node_form"){
$form['title']['#title'] = t('Event Name');
}
}
i changed title of Title in this way but i couldn't change body title help me?
You should not have to write code in order to modify the Body title in Drupal 7.
If you edit the Body field in your content type (at path admin/structure/types/manage/[content-type]/fields), you should be able to change the label from "Body" to another label/title you want.
Related
I have a content type, f.e mycontentype, which has titles, like:
Title - library1
another title - library1
yet another title - library1
so i went in the db and with a MySQL command, i updated all titles to
Title
another title
yet another title
My issue here is that in a view, i have as a field, the
Content: mycontenttype
which i have set to the formatter as title link.
This brinks as the title the old title Title - library1, but when this link is clicked, we go the the node where the title is shown correctly.
if in the formatter i choose full content, i get again all data updated, including the correct title.
Of course i have cleared all caches, i have run update.php,
any ideas?
So you manually updated the title field in node table, and you probably forgot to update node_revision as well.
You may also have to run entity_get_controller('node')->resetCache($nids); $nids being the affected nodes.
Don't update the database manually, in this situation you could do something like this :
$nodes = node_load_multiple(array(), array('type' => 'mycontentype'));
foreach ($nodes as $nid => &$node) {
$node->title = preg_replace('/^(.+?)\s+-\slibrary1$/', '$1', $node->title);
$node->save();
}
I want to wrap h2 tags around a 'content type' text field (the field "product_title"), as a default setting, that the user cannot change.
I have tried to add this snippet in the file template.php in my theme:
function mytheme_preprocess_field(&$vars) {
if($vars['element']['#field_name'] == 'field_produktnamn'){
$vars['items']['0']['#markup'] = '<h2>This works</h2>';
}
}
But I can't figure out how to keep the original field content. I only want to add h2 tags, not replace the text content.
Or maybe I should go about this another way?
try using this instead:
$vars['items']['0']['#prefix'] = '<h2>';
$vars['items']['0']['#suffix'] = '</h2>';
I need to add a custom base href, I have a organic groups multisite setup. I have a field field_site_url which renders the URL correctly how would I get this to print
I did this but it doesnt work
base href="what do i put here" target="_blank"
Any ideas please
Thanks
I get CCK / fields data into html.tpl.php in d7 by using a preprocess function in template.php:
function THEMENAME_preprocess_html(&$variables, $hook) {
$node = menu_get_object();
if($node)
{
$variables['myfield'] = $node->field_myfield['und'][0]['value'];
}
}
This sets up a $myfield variable you can output in html.tpl.php :
echo $myfield;
I developed a Content type of "Car Sales" with following fields:
Manufacturer
Model
Make
Fuel Type
Transmission (Manual/Automatic)
Color
Registered? (Yes/No)
Mileage
Engine Power
Condition (New/Reconditioned/Used)
Price
Pictures (Multiple uploads)
I have developed View of this Content Type to display list of cars. Now I want to develop a screen/view for individual Car Sale Record like this:
Apart from arranging fields, please note that I want to embed a Picture Gallery in between. Can this be achieved through Drupal 7 Admin UI or do I need to create custom CSS and template files? If I need to edit certain template files/css, what are those? I'm using Zen Sub Theme.
I would accomplish this by creating a page, and then creating a node template to accompany it. Start by creating a new node, and then record the NID for the name of the template.
Then, in your template, create a new file, and name it in the following manner: node--[node id].tpl.php
Then, in that file, paste in the following helper function (or you can put it in template.php if you're going to use it elsewhere in your site):
/**
* Gets the resulting output of a view as an array of rows,
* each containing the rendered fields of the view
*/
function views_get_rendered_fields($name, $display_id = NULL) {
$args = func_get_args();
array_shift($args); // remove $name
if (count($args)) {
array_shift($args); // remove $display_id
}
$view = views_get_view($name);
if (is_object($view)) {
if (is_array($args)) {
$view->set_arguments($args);
}
if (is_string($display_id)) {
$view->set_display($display_id);
}
else {
$view->init_display();
}
$view->pre_execute();
$view->execute();
$view->render();
//dd($view->style_plugin);
return $view->style_plugin->rendered_fields;
} else {
return array();
}
}
Then add the following code to your template:
<?php
$cars = views_get_rendered_fields('view name', 'default', [...any arguments to be passed to the view]);
foreach ($cars as $car): ?>
<div>Put your mockup in here. It might be helpful to run <?php die('<pre>'.print_r($car, 1).'</pre>'); ?> to see what the $car array looks like.</div>
<?php endforeach;
?>
Just change the placeholders in the code to whatever you want the markup to be, and you should be set!
As I mentioned above, it's always helpful to do <?php die('<pre>'.print_r($car,1).'</pre>'); ?> to have a visual representation of what the array looks like printed.
I use views_get_rendered_fields all the time in my code because it allows me to completely customize the output of the view.
As a Reminder: Always clear your caches every time you create a new template.
Best of luck!
I want to add new fields or propierties to an calendar event. How can I do it?
Thanks!
You need to
add new section to lightbox form
http://docs.dhtmlx.com/doku.php?id=dhtmlxscheduler:details_form
for new section of lightbox, set map_to value as name of new field
on server side add extra field to the list of fields in render command
This is how you would create a simple href link inside an event:
1) Go to the Event Configuration Console and create a custom field, under the section that says 'CUSTOM FIELD'. Give the field a name. In this example, call it 'url'. Select its type as 'TextArea'.
2) Create another custom field, call it 'link_title'.Also a 'TextArea'. Description is optional.
SAVE
3) Go to the 'Templates' section of the event console. Under the first section (... scheduler.templates.event_text=function(start,end,event){... ) where you can input text, put ->
return "<b> "+event.text+"</b><br><br>" + event.link_title + "";
SAVE
When you go to create your event from the main calendar, you will see extra fields. Type in them, save your event, and voila. Toot Sweet.
What do you mean by calendar event?
Is it adding a new event?, then it must be done using lightbox(built-in option)
scheduler.config.lightbox.sections=[
{ name:"description", height:50, map_to:"text", type:"textarea", focus:true },
{ name:"location", height:43, map_to:"event_location", type:"textarea",
default_value:"Blackheath Avenue London,Greenwich,Greater London SE10 8XJ,UK"},
{name:"recurring", height:115, type:"recurring", map_to:"rec_type",
button:"recurring"},
{ name:"time", height:72, type:"time", map_to:"auto"}
];
each tag used in here is suppoted by the plugin,,,,in you want to have a seperate customize lightbox go to
http://docs.dhtmlx.com/scheduler/custom_details_form.html
This is the preview