Having trouble including PHP into a story

8 views
Skip to first unread message

Dave

unread,
Mar 11, 2016, 4:26:32 PM3/11/16
to nikola-discuss


I have a page:

my_page.php

I have compilers: PHP and allowed .php as an extension for the page. The page is being built so all good there.

But my page is built incorrectly. Firstly the page ends with:

<meta property="og:description" content="

This was "fixed" by removing from the template:
##    ${helper.open_graph_metadata(post)}
##    ${helper.twitter_card_information(post)}



But still, the page builds incorrectly only using about 3/4 of the theme.


The php is simple enough
<?php


if(!isset($_POST))return;

$email
= $_POST['email'];
$name
='';
$list
='<id here>';

$url  
= "https://domain.com";

if($email=='' || $list=='')
{
   
return false;
}

$postdata
= http_build_query(
        array
(
       
'name' => $name,
       
'email' => $email,
       
'list' => $list,
       
'boolean' => 'true'
       
)
);
$opts
= array('http' => array('method'  => 'POST', 'header'  => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context  
= stream_context_create($opts);
$result
= file_get_contents($url.'/subscribe', false, $context);

?>


just handling a form. If I test with


<?php
 echo
"hello world";
?>

then it works, so something above is breaking something



prosrcmedia

unread,
Mar 11, 2016, 4:32:37 PM3/11/16
to nikola-discuss
Ask a question solve the issue.

This is still a problem for PHP

> ## ${helper.open_graph_metadata(post)}
> ## ${helper.twitter_card_information(post)}


But the other issue I think I have sorted (my fault)






On 11/03/2016 16:26, Dave wrote:
>
>
> I have a page:
>
> my_page.php
>
> I have compilers: PHP and allowed .php as an extension for the page. The
> page is being built so all good there.
>
> But my page is built incorrectly. Firstly the page ends with:
>
> |
> <meta property="og:description" content="
> |
>
> This was "fixed" by removing from the template:
> |
> ## ${helper.open_graph_metadata(post)}
> ## ${helper.twitter_card_information(post)}
>
> |
>
>
> But still, the page builds incorrectly only using about 3/4 of the theme.
>
>
> The php is simple enough
> |
> <?php
>
>
> if(!isset($_POST))return;
>
> $email =$_POST['email'];
> $name='';
> $list='<id here>';
>
> $url ="https://domain.com";
>
> if($email==''||$list=='')
> {
> returnfalse;
> }
>
> $postdata =http_build_query(
> array(
> 'name'=>$name,
> 'email'=>$email,
> 'list'=>$list,
> 'boolean'=>'true'
> )
> );
> $opts =array('http'=>array('method'=>'POST','header'=>'Content-type:
> application/x-www-form-urlencoded','content'=>$postdata));
> $context =stream_context_create($opts);
> $result =file_get_contents($url.'/subscribe',false,$context);
>
> ?>
>
> |
>
> just handling a form. If I test with
>
>
> |
> <?php
> echo "hello world";
> ?>
> |
>
> then it works, so something above is breaking something
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "nikola-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nikola-discuss/GPRiYg6NJEM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> nikola-discus...@googlegroups.com
> <mailto:nikola-discus...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Chris Warrick

unread,
Mar 12, 2016, 3:06:43 AM3/12/16
to Nikola—Discuss
On 11 March 2016 at 22:31, prosrcmedia <prosr...@gmail.com> wrote:
> Ask a question solve the issue.
>
> This is still a problem for PHP
>
>> ## ${helper.open_graph_metadata(post)}
>> ## ${helper.twitter_card_information(post)}
>
>
>
> But the other issue I think I have sorted (my fault)

We need some description of this page for various places. If you don’t
provide a description via the .. description: tag, we default to
taking the first few hundred characters from the page text. Which end
up being fragments of your PHP code, and so it breaks.

Providing a friendly plaintext description should fix it.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

prosrcmedia

unread,
Mar 12, 2016, 7:47:59 AM3/12/16
to nikola-...@googlegroups.com
ahh yes, of course, makes sense. I think I would have spotted this if I
didn't only get to spend time on nikola at nights :)
Reply all
Reply to author
Forward
0 new messages