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

profix898’s picture

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) { ... }

Julien PHAM’s picture

Thanks, that is what I needed, this in_preview stuff... btw is there somewhere a listing for each node states?

profix898’s picture

... a listing for each node states?

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 ...

Julien PHAM’s picture

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:

["attachments"]=>  array(4) { [0]=>  array(9) { ["aid"]=>  string(2) "39" ["title"]=>  string(12) "calzamin.jpg" ["description"]=>  string(0) "" ["fid"]=>  string(2) "32" ["filename"]=>  string(12) "calzamin.jpg" ["size"]=>  string(5) "32183" ["hidden"]=>  string(1) "1" ["deleted"]=>  bool(false) ["working"]=>  bool(false) }

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

profix898’s picture

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

$attachments = $node['attachments']; OR $attachments = $node->attachements;
foreach ($attachments as $item) {
  echo $item['title'];
}
Julien PHAM’s picture

Thanks. What I find strange too is that there is no file path in this table... so where is this file path ? ;)