Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2016-07-16 18:25:30
- macosa
- New Member
- Registered: 2016-07-16
- Posts: 7
PHP and <txp:custom_field />
Hello,
I just start to read about php and right now dont have a lot of information about it and dont anderstand it a lot) I found php script for taking open graph meta from URL. If I use URL at this script its OK but than i use <txp:custom_field /> for changing URL at articles its dont work. Can you help to solve it plese?)
<txp:php>
$page_content = file_get_contents('<txp:custom_field name="filed"/>');
$dom_obj = new DOMDocument();
$dom_obj->loadHTML($page_content);
$meta_val = null;
foreach($dom_obj->getElementsByTagName('meta') as $meta) {
if($meta->getAttribute('property')=='og:image'){
$meta_val = $meta->getAttribute('content');
}
}
echo $meta_val;
</txp:php>
Offline
#2 2016-07-16 19:11:17
- macosa
- New Member
- Registered: 2016-07-16
- Posts: 7
Re: PHP and <txp:custom_field />
Did It)
<txp:php>
$page_content = file_get_contents(custom_field(array(‘name’ => ‘filed’)));
$dom_obj = new DOMDocument();
$dom_obj->loadHTML($page_content);
$meta_val = null;
foreach($dom_obj->getElementsByTagName(‘meta’) as $meta) {
if($meta->getAttribute(‘property’)==‘og:image’){
$meta_val = $meta->getAttribute(‘content’); } } echo $meta_val; </txp:php>Offline
Pages: 1