Extension CSS value from Extension Properties

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Bishu
User
Posts: 429

Extension CSS value from Extension Properties

Post by Bishu »

I have created a Custom Extension with the CSS, where I would like to change the value of CSS from the Extension Properties.
The extension files are

1) forumlayout.xml

<?xml version="1.0" encoding="iso-8859-1" ?>
<ew-extension name="Layout" version="13.0.6" type="Forum Layout" author="PHPMaker Forum">
<description>
<![CDATA[This Extension is created by PHPMaker Forum for the Needs of Forum Users

Note: Layout Extension is not a part of PHPMaker. Please read "Third-Party Tools" in the help file.
]]>
</description>
<file>forumlayout.zip</file>
<Project>
<Attribute name="ContentLeft" type="Boolean" default="False"/>
<Attribute name="C_LeftWidth" type="Integer" default="0"/>
<Attribute name="ContentRight" type="Boolean" default="False"/>
<Attribute name="C_RightWidth" type="Integer" default="0"/>
</Project>
</ew-extension>

2) control.xml

<?xml version="1.0" standalone="yes"?>
<phpmaker.forumlayout date="2015/09/22" version="13.0.6" desc="forumlayout" author="PHPMaker Forum">
<control id="layoutcss" type="other" action="add"
ifiles="layoutcss.css"
ofolderid="_css"
ofile="layout" oext="css">
<session type="key" value="layout" />
</control>
</phpmaker.forumlayout>

3) layoutcss.css

<!--##session layoutcss##-->

.ewLeftContent {
background-color:inherit;
color: inherit;
<!--##
var EXT = ew_GetExtObj(sExtName);
if (EXT.Enabled && EXT.PROJ) {
var sContentLeftValue = ew_GetExtPrp(EXT.PROJ.Properties, "C_LeftWidth");
if (ew_IsNotEmpty(sContentLeftValue)){
iLeftWidth = sContentLeftValue;
}
}
##-->
width: <!--##=iLeftWidth##-->px;
<!--## } else { ##-->
width: 0px;
<!--## } ##-->
vertical-align: top;
padding: 0;
}

.ewRightContent {
background-color:inherit;
color: inherit;
<!--##
var EXT = ew_GetExtObj(sExtName);
if (EXT.Enabled && EXT.PROJ) {
var sContentRightValue = ew_GetExtPrp(EXT.PROJ.Properties, "C_RightWidth");
if (ew_IsNotEmpty(sContentRightValue)){
iRightWidth = sContentRightValue;
}
}
##-->
width: <!--##=iRightWidth##-->px;
<!--## } else { ##-->
width: 0px;
<!--## } ##-->
vertical-align: top;
padding: 0;
}

#ewLeftContent, #ewRightContent {
display: table-cell;
}

<!--##/session##-->

The css file is not copied to the PHPCSS with the require value.


mobhar
User
Posts: 11702

Post by mobhar »

Because you have not added the "copy" action into "control.xml" file, yet.

Always refer to the existing condition. You may see the example of "copy" action from "CAPTCHA" extension.


Bishu
User
Posts: 429

Post by Bishu »

2) control.xml

<?xml version="1.0" standalone="yes"?>
<phpmaker.forumlayout date="2015/09/22" version="13.0.6" desc="forumlayout" author="PHPMaker Forum">
<control id="layoutcss" type="copy" action="add"
ifiles="layoutcss.css"
ofolderid="_css"
ofile="layout" oext="css">
<session type="key" value="layout" />
</control>
</phpmaker.forumlayout>

If I change the type="copy" than it copy the exact what I have written on the css.
But on the CSS file I would like to get the value from Extension properties.


mobhar
User
Posts: 11702

Post by mobhar »

In addition to "copy" action, then you should include the "add" action. Again, see the sample in "control.xml" of "CAPTCHA" extension.


Bishu
User
Posts: 429

Post by Bishu »

@mobhar thanks for help.
As from the example I change th control as
2) control.xml

<?xml version="1.0" standalone="yes"?>
<phpmaker.forumlayout date="2015/09/22" version="13.0.6" desc="forumlayout" author="PHPMaker Forum">
<control id="layout.css" type="other" action="add"
ifiles="layout.css"
ofolderid="_css"
ofile="layout" oext="css">
<session type="key" value="layoutcss" />
</control>
</phpmaker.forumlayout>

Now my code goes wrong some where on css
.ewLeftContent {
background-color:inherit;
color: inherit;
<!--##
var EXT = ew_GetExtObj(sExtName);
if (EXT.Enabled && EXT.PROJ) {
var sContentLeftValue = ew_GetExtPrp(EXT.PROJ.Properties, "C_LeftWidth");
if (ew_IsNotEmpty(sContentLeftValue)){
iLeftWidth = sContentLeftValue;
##-->
width: <!--##=iLeftWidth##-->px;
<!--## } else { ##-->
width: 0px;
<!--## }
} ##-->
vertical-align: top;
padding: 0;
}

I am unable to figure it out.


mobhar
User
Posts: 11702

Post by mobhar »

Double check your code in "control.xml" file. You should have two control ids in there, not only one.

See the following example from CAPTCHA extension; one for write the "ewcaptcha" section value to css file, and the other for copy the file (you need to adjust it according to your needs):

<!--
	Write captcha
-->
<control id="ewcaptcha.php" type="other" action="add"
		ifiles="ewcaptcha.php" ofile="ewcaptcha" oext="*"
		cond="function/IsReCaptcha/Boolean/EQ/False">
	<session type="key" value="ewcaptcha"/>
</control>
		
<!-- recaptcha -->
<control id="recaptcha" type="copy" action="add"
		ofolder="ReCaptcha"
		ifolder="ReCaptcha"
		cond="function/IsReCaptcha/Boolean/EQ/True" />

Post Reply