Hello,
This question involves some PHP coding. I have a website which has content that repeats on a couple of pages. The website has no database but I have a 'data' directory in which I have a few .inc files which contain hardcoded PHP arrays. I then have some PHP code which iterates through those arrays and echos the data on the page with the HTML formatting that I need.
Here is an example of a data file called countries.inc
<?php
/* This is an array of data used to dynamically create a list of countries, it contains country-code, name and flag */
$countries = array (
array("US","United States of America", "usa.png"),
array("UK","United Kingdom", "gb.png"),
array("FR","France", "france.png"),
array("ES","Spain", "spain.png"),
);
?>
Now on my PHP page I use the above file like this:
<?php
include('data/countries.inc'); // Load the data from the external inc file
$countries_count = sizeof($countries);
foreach($countries as $country){ // Dynamically create each item in the loop
echo "<div class='col-md-6 service-box'>
<div class='classic-testimonials item'>
<span>$country[1]</span>
<span>$country[2]</span>
<span><img src='images/countries/". $country[3] ."' /></span>
</div>
</div>";
}
?>
I am wondering if it is possible to extend the CouchCMS code to handle these arrays, to somehow get them controlled by the CMS. It might require writing some new PHP code into the CouchCMS stuff, or maybe there is an easier way.
I'd love your input on this, I think it would be a useful feature for the CMS.
Regards,
Lucas
This question involves some PHP coding. I have a website which has content that repeats on a couple of pages. The website has no database but I have a 'data' directory in which I have a few .inc files which contain hardcoded PHP arrays. I then have some PHP code which iterates through those arrays and echos the data on the page with the HTML formatting that I need.
Here is an example of a data file called countries.inc
<?php
/* This is an array of data used to dynamically create a list of countries, it contains country-code, name and flag */
$countries = array (
array("US","United States of America", "usa.png"),
array("UK","United Kingdom", "gb.png"),
array("FR","France", "france.png"),
array("ES","Spain", "spain.png"),
);
?>
Now on my PHP page I use the above file like this:
<?php
include('data/countries.inc'); // Load the data from the external inc file
$countries_count = sizeof($countries);
foreach($countries as $country){ // Dynamically create each item in the loop
echo "<div class='col-md-6 service-box'>
<div class='classic-testimonials item'>
<span>$country[1]</span>
<span>$country[2]</span>
<span><img src='images/countries/". $country[3] ."' /></span>
</div>
</div>";
}
?>
I am wondering if it is possible to extend the CouchCMS code to handle these arrays, to somehow get them controlled by the CMS. It might require writing some new PHP code into the CouchCMS stuff, or maybe there is an easier way.
I'd love your input on this, I think it would be a useful feature for the CMS.
Regards,
Lucas