Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Julien PHAM on
Hi,
I have a little problem. I have setup my teaser to remove all html tags, but then when I write an article and click on "preview", this is this setting which is beeing used.
How can I test if I'm in preview mode? The $page variable has the same value between the teaser and the preview mode.
Thanks
Comments
where called from
Where do you call your 'remove_html_tags' function from?
If you are using hook_nodeapi, you have access to $node, right?
Then you can do test to distinguish normal page view and preview.
if ($node->in_preview) { ... }
Thanks, that is what I
Thanks, that is what I needed, this in_preview stuff... btw is there somewhere a listing for each node states?
Listing?
What Do you mean? Do you want a list of available variables?
Simply make a
var_dump($node)
and you will see what information you can draw from $node ...So I guess this way we could
So I guess this way we could retrieve the attachment list without printing the whole body isn't it?
When I do this var_dump from $node, I get this one about attachments:
How do I print a field of this array item for instance? Attachment is an array of 4 objects, how do I print the "title" of the first object?
Thanks
print items
You can access $node just like every other variable/array.
echo $node['attachments'][0]['title'];
for example (replace 0 with the item index to be displayed),
or to print a list of attachments
Thanks. What I find strange
Thanks. What I find strange too is that there is no file path in this table... so where is this file path ? ;)