by
scratz » Thu Nov 21, 2024 11:04 am
Hello again @KK and @Trendoman,
Well, upon further testing, there are some odd differences with this .php stylesheet being rendered on the front end but only, it seems, with the pagebuilder method.
I have a template that via css can put a color/gradient overlay over a section (these sections will become blocks in pagebuilder). I have my own .php file (configured as @trendoman suggested) as a stylesheet so a user can set whatever colors they want per block. There are the default colors of the site but through Couch's AMAZING CMS framework and all of the contributors and help in these forums, I can make it to where the user can choose their own custom colors to use. These colors are pulled from the editables and set as vars to use in the stylesheet:
<head>- Code: Select all
....
...
<link href="<cms:show k_site_link />assets/css/theme.css" rel="stylesheet" />
<link href="<cms:show k_site_link />assets/css/user.php?page=<cms:show k_template_name />&post=<cms:show k_page_id />"
...
...
user.php- Code: Select all
<?php require_once( '../../smbcw_admin/cms.php' ); ?>
<cms:template parent='_donottouch_' hidden='1' />
<cms:content_type 'text/css' />
<cms:pages masterpage="<cms:gpc 'page' />" id="<cms:gpc 'post' />" >
<cms:if img_ovrly>
<cms:set overly_color1="<cms:show clr_one />" "global" />
<cms:set overly_color2="<cms:show clr_two />" "global" />
</cms:if>
<cms:if rvrs_grad >
<cms:set swap_clr="1" "global" />
</cms:if>
......
.hr-med {
width: 28rem;
margin: 1.25rem auto;
}
.hr-long {
width: 64rem;
margin: 1.25rem auto;
}
.bg-holder.overlay-color:before {
background: <cms:show overly_color1 />;
}
<cms:if swap_clr >
.bg-holder.overlay-gradient:before {
background: -o-linear-gradient(135deg, <cms:show overly_color1 /> 0, <cms:show overly_color2 /> 100%);
background: linear-gradient(-45deg, <cms:show overly_color1 /> 0, <cms:show overly_color2 /> 100%);
}
<cms:else />
.bg-holder.overlay-gradient:before {
background: -o-linear-gradient(135deg, <cms:show overly_color2 /> 0, <cms:show overly_color1 /> 100%);
background: linear-gradient(-45deg, <cms:show overly_color2 /> 0, <cms:show overly_color1 /> 100%);
}
</cms:if>
If I build a page from a regular template, with all the code on a single page (as opposed to pagebuilder), everything works great in Admin and on the front-end site - no problems.
However, in pagebuilder, as the blocks are being created, while still in the Admin section, everything works beautifully as expected. So, obviously the style is cascading from the php stylesheet and all of the querystring parameters are working. I build the blocks, and with the blocks I create a page. Even after I save the page, re-edit it, re-save it, everything renders perfectly in the Admin section - each block looks and renders as it should.
However when the page renders on the front end, whether it's my testing server or my hosting server, the front end won't show the custom colored overlay, but it WILL show it's default overlay. This means the element style is being read but the style isn't coming from the php stylesheet, only the default site one. I can tell from other styling on the rendered front-end page that SOME of the php style is referenced (namely, the .hr-med and .hr-long ) so I know the php style sheet is being referred to by this page.
But why isn't the color coming through? The "source" shows the correct style inside the html element. Couch is rendering all of the editables on the page correctly and when I look at <head> and look at the Source / Network tab, the link shows the correct query params and that it's a UTF-8 css/text stylesheet. Again, some of that coding is getting pulled which is proof it's getting referred.
I was thinking the issue was because 1 page would now be trying to render the same variable at different parts of the page because of the distinct blocks (overly_color1, overly_color2). And I'm not sure that's not it, but then why would it work fine in the Admin section? Is it because the Admin section is iFrames? But even if that were the case, wouldn't at least the first color, or the last colored block render correctly?
I'm totally at a loss as to why the colors aren't being pulled and rendering. Has anyone else come across anything like this?