I'd like to keep things really simple for my users. Is there a way to have to body field of a content type always have the value "[video]" ?

Comments

travist’s picture

Status: Active » Fixed

Sure! You just need to set up a template for your node type using the Contemplate module.

jmlavarenne’s picture

That works, thanks. I have tried to do it manually in the node's tpl file, but I can't seem to set $node->body = "[video]";

I'll have to read up on this.

scottrigby’s picture

Hi, can you verify that this works using the .tpl file? I'd rather use this than contemplate (which I found more difficult to use). If so, what is the appropriate code to print the video (the code just above, or...)?
Thanks in advance!

travist’s picture

For a TPL file, you will need to use the actual API call (which is actually better anyway). Use the following code in your TPL file to get the video for that node...

<?php print flashvideo_get_video($node); ?>

And if you wish to show the thumbnail, use....

<?php print flashvideo_get_thumbnail($node); ?>
scottrigby’s picture

Great travist, thanks! Does this apply to Drupal 6 as well?
(BTW, I know this doesn't match the issue's version #... but I shouldn't change the issue Version just for this question, or post an entirely new issue just for this should I? Thanks also for this protocol advice - cheers!)

travist’s picture

This should also work for Drupal 6. :)

jmlavarenne’s picture

<?php print flashvideo_get_video($node); ?> removes the need for [video]?

If so I definitely prefer that route to contemplate.

travist’s picture

<?php print flashvideo_get_video($node); ?> does the exact same thing as [video]. I just put the ability to have the "[video]" tag for the users who are not savvy with PHP. I wanted to also design a solution that makes it easy for video bloggers to post their videos using a simple tag instead of opening up PHP to all users.

jmlavarenne’s picture

The more options, the best!

ms1’s picture

I created two fields with default values and hid them. I made it in a long process

What I did was
1. Put this code in my 'template' file of the theme.

<?php
if ((arg(0) == 'node') && (arg(1) == 'add') && (arg(2) == 'videos')){
function phptemplate_node_form($form) {
return _phptemplate_callback('edit_videos', array('user' => $user, 'form' => $form));
}
}
if ((arg(0) == 'node') && (arg(2) == 'edit')){
    $node = node_load(array('nid' => arg(1)));
function phptemplate_node_form($form) {
          return _phptemplate_callback('edit_videos', array('user' => $user, 'form' => $form));
}
}
?>

Note:- Please replace your content-type in place of videos

2. Created two fields 'ABC' and 'DEF' and gave them default values as [video] and [thumbnail].

3.then created another file in my theme folder as 'edit-videos.tpl.php' and put the code as

<?php
unset($form['field_ABC']);
unset($form['field_DEF']);
print drupal_render($form);
?>

this will hide them in creation as well as editing.

4. Whereas to hide the labels as well as default contents in teasers and node, I configured them through 'manage fields' of the content-type.

I know its long, but I didn't knew that there were other alternatives and already I bother travist every now and then with other issues.

But this method works well.

Regards

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mrgoltra’s picture

subscribing

aznboy’s picture

subscribing