This example adds some
keywords metadata:
$keywords = 'monkey, ape, chimpanzee, gorilla, orang-utan';
$document->setMetaData('keywords', $keywords);
Adding http-equiv metadata is very similar. Imagine we want to turn off browser
theme styling. We can use the http-equiv metadata type MSTHEMECOMPATIBLE:
$document->setMetaData('MSTHEMECOMPATIBLE', 'no', true);
It is that final parameter, when set to true, which tells the method that the metadata
is http-equiv.
The getMetaData() method works in much the same way, except we retrieve
values. Imagine we want to append some keywords to the document:
$keywords = explode(',', $document->getMetaData('keywords'));
$keywords[] = 'append me';
$keywords[] = 'and me';
$document->setMetaData('keywords', implode(',', $keywords));
This gets the existing keywords and explodes them into an array; this ensures we
maintain the keyword comma separators. We proceed to add some new keywords to
the array. Finally, we implode the array and reset the keywords metadata.
Custom Header Tags
If we want to add a different type of tag, not a script, CSS, or metadata, we can use
the addCustomTag() method.
Pages:
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362