# PHP snippets in prefix break preview

**URL:** <https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202>\
**Category:** RapidWeaver Classic\
**Created:** [February 13, 2019, 11:36am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202 "2019-02-13T11:36:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![djr13](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@djr13](https://forums.realmacsoftware.com/u/djr13)\
**Post date:** [February 13, 2019, 11:36am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/1 "2019-02-13T11:36:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [February 13, 2019, 12:32pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/2 "2019-02-13T12:32:21Z")

</div>

Show us the code.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [February 13, 2019, 1:16pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/3 "2019-02-13T13:16:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joeworkman](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/joeworkman/32/23780_2.png) [@joeworkman](https://forums.realmacsoftware.com/u/joeworkman)\
**Post date:** [February 13, 2019, 2:44pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/4 "2019-02-13T14:44:17Z")

</div>

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.

> **[Sitelok add-on for Stacks Pro](https://www.weavers.space/stacks/sitelok)**
>
> The Sitelok stacks allow you to easily integrate Sitelok by Vibralogix into your RapidWeaver projects. Its never been easier to build memebership sites or a full feature user login system. With these stacks, you no longer have to worry about adding...

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [February 13, 2019, 4:00pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/5 "2019-02-13T16:00:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adger](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@adger](https://forums.realmacsoftware.com/u/adger)\
**Post date:** [February 25, 2019, 10:08pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/6 "2019-02-25T22:08:22Z")

</div>

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** `

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [February 25, 2019, 10:34pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/7 "2019-02-25T22:34:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![djr13](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@djr13](https://forums.realmacsoftware.com/u/djr13)\
**Post date:** [February 25, 2019, 10:48pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/8 "2019-02-25T22:48:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [February 26, 2019, 5:21am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/9 "2019-02-26T05:21:49Z")

</div>

> [@djr13](#):
>
> Has something changed within RapidWeaver?

@dan, do you know?

---

<div class="post-metadata">

**Author:** ![mdlong](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mdlong](https://forums.realmacsoftware.com/u/mdlong)\
**Post date:** [February 26, 2019, 7:37am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/10 "2019-02-26T07:37:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adger](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@adger](https://forums.realmacsoftware.com/u/adger)\
**Post date:** [February 26, 2019, 10:10am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/11 "2019-02-26T10:10:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [February 26, 2019, 10:52am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/12 "2019-02-26T10:52:26Z")

</div>

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

 ![](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/8/85253d5270494e5431f3bfab31197622a98ac703.jpeg)

---

<div class="post-metadata">

**Author:** ![adger](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@adger](https://forums.realmacsoftware.com/u/adger)\
**Post date:** [February 26, 2019, 11:05am UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/13 "2019-02-26T11:05:45Z")

</div>

Doh!  
Thanks @dan, it’s easy when you know how 👍

---

<div class="post-metadata">

**Author:** ![instacks](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/instacks/32/23339_2.png) [@instacks](https://forums.realmacsoftware.com/u/instacks)\
**Post date:** [February 26, 2019, 1:09pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/14 "2019-02-26T13:09:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/system/32/25301_2.png) [@system](https://forums.realmacsoftware.com/u/system)\
**Post date:** [March 28, 2019, 11:09pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/15 "2019-03-28T23:09:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/dan/32/28516_2.png) [@dan](https://forums.realmacsoftware.com/u/dan)\
**Post date:** [August 12, 2026, 8:27pm UTC](https://forums.realmacsoftware.com/t/php-snippets-in-prefix-break-preview/25202/16 "2026-08-12T20:27:41Z")

</div>


