Elements transcribing PHP code?

I am continuing the process of trying to migrate my working stand-alone blog to Elements.

Still waiting on a response on how to handle included PHP files. For the moment, I am just moving the files into a folder in the website root folder.

PHP code that is working in the standalone version, isn’t working in Elements because it seems to be transcribed in some way?

<label class="block cursor-pointer">
<input type="checkbox" name="tags[]" 
value="<?php echo htmlspecialchars($tag); ?>"class="tagCheckbox mr-2"
<?php echo in_array($tag, $tagsFilter) ? 'checked' : ''; ?>
onchange="submitForm()">
<?php echo htmlspecialchars($tag); ?>
</label>

Original PHP Code: see above.

<label class="block cursor-pointer">
<input type="checkbox" name="tags[]"
value="bengal" class="tagCheckbox mr-2"
onchange="submitForm()">
bengal
</label>

Correct output shown in browser source for standalone: see above.

<label class="block cursor-pointer">
<input type="checkbox" name="tags[]"
value="bengal" class="tagCheckbox mr-2"
<!--RW::PHP8RW::PHP-- />
onchange="submitForm()"&gt; 
bengal
</label>

Incorrect output shown in browser source for Elements: see above.

Looks like Elements is doing some processing on the PHP?

@dan Ah yes, code mutation rears it’s ugly head once again - get the pitch forks out :wink:

Hey @logrunner,

Have you seen the “Backend” feature we added recently? I think this will help here, you can find the docs for it here Backend | RapidWeaver Elements Docs

Yes, we process the HTML to ensure everything is correct. I’ve been able to reproduce the issue you’re seeing and have a fix ready in the next build.

1 Like

@tpbradley I’ll try the backend; seems like it will resolve my issue. :slightly_smiling_face:

I’ll await the fix. :+1:

@tpbradley, Was this meant to be fixed in 0.67?

I have a line of PHP code that starts like this:

<input type="text" name="search" value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>" ...

and it is getting transcribed to this:

<input type="text" name="search" value="<!--RW::PHP0RW::PHP-->" ...

So it looks like it isn’t fixed yet?

Thanks for reporting this, I’ve been able to reproduce it here and looking into it :+1:

2 Likes

Hi Tom,

I’ve got the same issue.

My code is…

<input type="text" name="search" placeholder="Search activities" class="px-3 py-2 border-orange-500 rounded-[3px]" value="<?php echo htmlspecialchars($_GET['search'] ?? ''); ?>">

Which is rendered as…

<input type="text" name="search" placeholder="Search activities" class="px-3 py-2 border-orange-500 rounded-[3px]" value="<!--RW::PHP2RW::PHP-->">

Thanks,

John

Thanks guys, I’ve just added fixed this! :tada:

1 Like

That’s great. Do we have to wait for the next release?

Yes, a new build should be available soon.

1 Like

Thanks @tpbradley - seems like the issued is fixed in 0.6.9. :+1:

1 Like

Hi @tpbradley Seems this issue is not quite resolved in 0.6.9?

My PHP source code:

            <!-- Category Dropdown -->
            <select id="category-select" name="category" class="px-3 py-1 border border-gray-400  bg-white text-black rounded hover:border-gray-800 transition  appearance-none" onchange="submitForm()">
                <option value="">All Categories</option>
                <?php foreach ($categories as $category): ?>
                    <option value="<?php echo htmlspecialchars($category); ?>" <?php if (isset($_GET['category']) && $_GET['category'] === $category) echo 'selected'; ?>>
                        <?php echo htmlspecialchars($category); ?>
                    </option>
                <?php endforeach; ?>
            </select>

The code shown in the browser ‘Show Page Source’ is this:

 <!-- Category Dropdown -->
  <select id="category-select" name="category" class="px-3 py-1 border border-gray-400  bg-white text-black rounded hover:border-gray-800 transition  appearance-none" onchange="submitForm()">
      <option value="">All Categories</option>
      <option value="Bengal" &lt;!--rw::php5rw::php--&gt;> Bengal </option>
      <option value="Burmese" &lt;!--rw::php5rw::php--&gt;> Burmese </option>
      <option value="Cornish Rex" &lt;!--rw::php5rw::php--&gt;> Cornish Rex </option>
      <option value="Persian" &lt;!--rw::php5rw::php--&gt;> Persian </option>
      <option value="Siamese" &lt;!--rw::php5rw::php--&gt;> Siamese </option>
      <option value="Tonkinese" &lt;!--rw::php5rw::php--&gt;> Tonkinese </option>
  </select>

I have scanned the browser source for !–rw and this is the only area where ‘transcribing’ (if that’s the right word?) is occurring.

Ah yes, I’ve been able to reproduce this here and will try and get a fix in for the next release!

1 Like

Good news, there’s a fix in the next release that should be available tomorrow :grin:

2 Likes

Hi @tpbradley - Yes, confirmed fixed in V0.7.0 - Thanks. :grinning:

2 Likes