Forum for discussing general topics related to Couch.
20 posts Page 1 of 2
Hi

I was looking to be able to edit a sites styles/colours of div background colours and CSS from the admin side and found the guide: viewtopic.php?f=8&t=7371 and using KK's method but don't see to work for some reason

I created styles.php and added it into the css folder and add the require_once and invoke into the styles.php file and then modified my line to be <link rel="stylesheet" href="https://www.domainname.co.uk/cmsdemo/css/styles.php?v=<cms:show k_page_modification_date" type="text/css" /> but am getting the following error showing

ERROR! ATTRIB_NAME: Invalid char """ (line: 13 char: 470)

Not sure where I have gone wrong as followed KK's instructions in the forum post

Thank you in advance

I am using the latest version of couchcms

Be good if a colour picker can be used as clients won't know CSS and how to change colours of div backgrounds etc. using hex codes

UPDATE: It works if I remove ?v=<cms:show k_page_modification_date from the line: <link rel="stylesheet" href="https://www.domainname.co.uk/cmsdemo/css/styles.php?v=<cms:show k_page_modification_date" type="text/css" /> but then in the admin side on the left, it appears as css/styles.php but it says No Editable Regions defined
<link rel="stylesheet" href="https://www.domainname.co.uk/cmsdemo/css/styles.php?v=<cms:show k_page_modification_date" type="text/css" />

Please notice the Couch statement highlighted above - it is missing the closing "/>" bracket and hence the error.

The rectified code would be -
Code: Select all
<link rel="stylesheet" href="https://www.domainname.co.uk/cmsdemo/css/styles.php?v=<cms:show k_page_modification_date />" type="text/css" />

Hope this helps.
Ahh how silly of me, sorry

I'll try it shortly and post a update

Thank you KK
Hi

Just a update

I put the updated line of code in: <link rel="stylesheet" href="https://www.domainname.co.uk/cmsdemo/css/styles.php?v=<cms:show k_page_modification_date />" type="text/css" />

On the couchcms side, it has got css/styles.php on the left so click on it but it says No Editable Regions defined. I don't understand how the colours of css styles can be changed from couchcms admin side
Now that the css/styles.php template is registered, you may define editable regions within it e.g. for background-color, font-family etc. (i.e. just like regular templates).

For the frontend, now define normal CSS rules and use the values from the editable regions you defined above e.g.
Code: Select all
body {
   background-color: <cms:show body_background_color />;
}

h1, h2, h3, h4, h5, h6 {
   font-family: <cms:show heading_font_family />;
}

This way your CSS file is now dynamic as you can change the values it shows from the backend.

Hope this explanation makes it easy for you to grasp the technique.
I have done that but still showing No editable regions defined, the coding I have is below

Code: Select all
<?php require_once( '../cms/cms.php' ); ?>
<cms:content_type 'text/css' />
body {
   background-color: <cms:show body_background_color />;
   padding-top: 54px;
}

@media (min-width: 992px) {
  body {
    padding-top: 56px;
    background-color: <cms:show body_background_color />;
  }
}

.card {
  height: 100%;
}
<?php COUCH::invoke(); ?>


The styles.php is inside the css folder on the server
still showing No editable regions defined

How would it show any editable region when you haven't defined any? (at least not that I can see from your code).

Please define a <cms:template> block and then place your <cms:editable> definitions within it as you do for all other templates -
Code: Select all
<?php require_once( '../cms/cms.php' ); ?><cms:content_type 'text/css' />
<cms:template>
    <cms:editable name='body_background_color' type='text' width='100' />
    ..
    .. other editable regions ..
    ..
</cms:template>
body {
   background-color: <cms:show body_background_color />;
   padding-top: 54px;
}

@media (min-width: 992px) {
  body {
    padding-top: 56px;
    background-color: <cms:show body_background_color />;
  }
}

.card {
  height: 100%;
}
<?php COUCH::invoke(); ?>

Make sure to visit the template as super-admin for the regions to be picked up by the admin-panel.
ahh ok sorry my mistake, I missed that out from the coding, sorry
Hi KK,

I have tried to turn my CSS into a couch template by adding the .php to it and all other pheri-pheri, However, I am unable to load it up in the CMS admin section. I am still testing out on my local wamp server and I can't load it up on web browser for it to be added into the couch template at the cms back end.

How can I invoke the css template to edited from the back end.

NOTE: I used the <cms:show k_site_link /> tag to add the necessary site address to the css link.

Thank you.
Toheeb, the working approach is outlined by KK viewtopic.php?f=2&t=7406#p10769 Check if you have done all the steps.
20 posts Page 1 of 2
cron