I had a chance to test this out and after further inspection I don't think editing all additional contents will be possible on one page.
Please imagine the example below for easier understanding:
Page 1
- content (not additional)
- additional_content_1
- additional_content_2
Page 2
- content (not additional)
- additional_content_1
- additional_content_2
When we are listing everything on Page 1, it shows as:
Page 1
- content (not additional)
- additional_content_1
- additional_content_2
- additional_content_1 (from Page 2)
- additional_content_2 (from Page 2)
WonderCMS works in a way that reads these "additional_content" from the database and displays them in their own <div>'s.
Example of how this is displayed in HTML:
Code: Select all
<div data-target="pages" id="addition_content_1" class="editText editable">Additional content from Page 1</div>
<div data-target="pages" id="addition_content_2" class="editText editable">Additional content from Page 1</div>
<div data-target="pages" id="addition_content_1" class="editText editable">Additional content from Page 2</div>
<div data-target="pages" id="addition_content_2" class="editText editable">Additional content from Page 2</div>
The problem comes when it's time so save changes, as you are describing - this happens:
Each time you make a change to the same "id" listed below (additional_content_1 and _2), your content doesn't get saved OR worse, it gets overwritten because it has the same id. These id's are a way of WonderCMS to recognize what field is being edited and saved.
So in short: listing all additional contents is possible on one page, but not editing because they would overwrite one another. To edit the additional fields, you will have to visit the page where the additional content originates from (so these additional contents can be edited if you visit their /page (their origin)).
The short script I pasted a couple of days earlier always shows all additional content fields on ALL pages. To make it only show on one page (for less confusion when visiting other pages), something like this would work.
Code: Select all
<?php
$class = "";
if ( wCMS::$loggedIn ) {
$class = "editText editable";
}
?>
<?php if (wCMS::$currentPage == 'home'): ?>
<?php foreach ( wCMS::db()->pages as $pageName => $page ): ?> <!-- loop though all pages -->
<div class="container" id="<?=$page->title; ?>">
<div class="row">
<div class="col-lg-12 text-center padding40">
<div class="<?php print $class; ?>"><?=$page->content; ?></div>
<?php
for ($i=1; $i!=10; $i++) {
$numberOfContent = "addition_content_".$i;
$fetch = $page->$numberOfContent;
$addition_content = $fetch;
if (empty($addition_content)) {
// do something if the additional content doesn't exist, maybe don't
} else { ?>
<div data-target="pages" class="<?php print $class; ?>" id="<?php print $numberOfContent; ?>"><?=$fetch;?></div>
<?php
}
}
?>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif ?>
Edit the above
home in
Code: Select all
<?php if (wCMS::$currentPage == 'home'): ?>
to show this only on a specific page.
This will list all additional fields on the home page. If you visit yourdomain.com/someOtherPage that has additional content fields, edit it there and it will display correctly on the home page.
Hope this helps, let me know if you need any assistance.