PHP snippets in prefix break preview

Hi. I use Sitelok for my website. It requires the addition of PHP snippets in the prefix area of a page. This has in the past been an issue with previewing pages in Rapidweaver but the issue was solved in earlier builds of RW8.

In the most recent builds of RW8 the problem has returned. I cannot preview a page if there is php code in the prefix section of the page - instead I receive a fatal error. The preview is fine if the code is removed.

I’d be grateful for any advice.

Many thanks

Dave

Show us the code.

1 Like

As Jannis (@instacks) said, post the code snippet here, make sure you mark it as code by selecting the code after pasting and choosing the </> in the toolbar.

Also a screenshot of the fatal error message that you’re getting would be helpful.

This is the reason that I made my Sitelok stacks. It adds all of the required code to the page and ensures that everything still works in RW.

Still I would like to see the PHP Code in order to help the user.

I’m seeing the same problem.

This is the php code:

<?php
$groupswithaccess="MEMBER"; 
require_once("/xxxx/slpw/sitelokpw.php");
?>

This is the RW preview error:

**Fatal error** : require_once(): Failed opening required '/xxxx/slpw/sitelokpw.php' (include_path='.:') in **/private/var/folders/4t/sp89pcxn2hqgk_4ywh_n_bbm0000gn/T/com.realmacsoftware.rapidweaver8/RapidWeaver/10366/document-0x7ff974d57c40/RWDocumentPagePreview/news/index.php** on line **3**

Which is correct, as you want to require a PHP file, which is only available on your server, not your Mac.

Try to exchange require_once with include_once

1 Like

Thanks everyone. The odd thing is that this behaviour is new. I have had that code on my site for years and previewing a web page worked perfectly until a few months ago. Has something changed within RapidWeaver?

@dan, do you know?

I do hope that this issue gets fixed as I use this same Sitelok PHP code in the Prefix section of my site on approximately 700 pages. It has worked perfectly well for many years, until now apparently.

Thanks @instacks, swappping out require_once for include_once does work, but having read up on the subtle difference I don’t think I’ll be using it in this case.

Let’s hope RapidWeaver restores the fix that worked before, please @dan?

It might help with local preview if you switch off the “Render PHP on Local Preview” in the General Preferences.

Doh!
Thanks @dan, it’s easy when you know how :+1:

@dan which doesn’t explain why it worked in 8.0.3.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.