1

Thanks to everybody who could help me !!

Since 3 days i'm trying to extract a color parameter without success.

I have a child theme of cassiopeia named cassiopeia_lolo installed by default. (Yellow star activated)

I implemented 3 color picker to change colors of website from admin. It's works fine.

I would like to display these color on theme admin to see the result and have an overview (aperçu) when changing the colors. So i need to access to color params from admin.

The skull and background skull have take the color picker colors

In the templateDetails.xml front site file i call the file /templates/cassiopeia_lolo/admin/style.php with that line :

<description>TPL_CASSIOPEIA_XML_DESCRIPTION<![CDATA[<link rel="stylesheet" type="text/css" href="../../templates/cassiopeia_lolo/admin/style.php" />]]></description>

but when the script style.php is loaded and i unncomment the following line of style.php it's don't works , the end of style.php is not loaded :

//$myTemplate = $app->getTemplate(true);

when i was using an other method (without using style.php) after this line who load the default template in a variable there is an php error saying "the template cassiopeia_lolo was not found.

Here are my files sorry if it's not very clear i will be happy to explain better the problem.

templates/cassiopeia_lolo/index.php

    <?php /*defined( '_JEXEC' ) or die( 'Restricted access' );

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;*/

/** @var Joomla\CMS\Document\HtmlDocument $this */

/*$app = Factory::getApplication();


$wa  = $this->getWebAssetManager();*/








$header_footer_color = $this->params->get('backgroundcolor', '#eee');
$logocolor = $this->params->get('logocolor', '#eee');
$logocolor2 = $this->params->get('logocolor2', '#eee');


?>





<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml" 
   xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" 
   xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">
<head>





<jdoc:include type="head" />
<?php include('templates/'. $this->template. '/color.php');?>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />  
<!--<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template.css?t=<? echo date(); ?>" type="text/css" />-->



<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template.css" type="text/css" /> 

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template-mobile.css" type="text/css" media="all" />
<link rel="shortcut icon" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/favicon.ico" />
<meta property="fb:app_id" content="171211871403248" />
  <style type="text/css">
    











</style>
</head>


  <body>
      <div class="main" id="mainCont">

          <!--Site-->

          <div class="header" > 
              <jdoc:include type="modules" name="Header" />
              <div class="navig">
                  <a href="<?php echo $this->baseurl ?>"> 
                        <div id="samy"><?php include('templates/'. $this->template. '/samy.php');?></div>
                  </a> 
                  <a href="<?php echo $this->baseurl ?>/administrator"><div id="roue"></div></a>
                  <jdoc:include type="modules" name="Nav" />
              </div>
          </div>

          <div class="banner">  
              <jdoc:include type="modules" name="Banner">
              <div id="logo"></div>
          </div>

          <div class="mobile-top">
              <div class="superdiv">
                  <div class="div1">
                      <a href="https://m.facebook.com/velorution.toulouse/?locale2=fr_FR"><img src="images/facebook.png"></a>
                  </div>

                  <div class="div2">
                      <a href="https://velorution-toulouse.org"><img src="images/samy5.png"></a>
                  </div>

                  <div class="div3">
                      <div class="burger2">
                          <div class="burger">
                              <span></span>
                          </div>
                      </div>
                  </div>
              </div>
              <div class='mobile'>
                  <div class="hamburger-overlay"></div>
                  <div class="mobile-content"></div>
              </div>    
          </div>
          <div class="content">
              <div class="avant">
                  <jdoc:include type="component" name="Flash" />
                  <div class="component">
                      <jdoc:include type="component" />
                  </div>
                  <div id="sidebar">
                      <jdoc:include type="modules" name="Sidebar" />
                  </div>
              </div>
          </div>

          <div class="footer">
              <div class="samy-logo-container">
                
              </div>
              <div class="bluefoot"></div>
              <jdoc:include type="modules" name="Footer" />
          </div>
      </div>

  <script src="/templates/cassiopeia_lolo/app-1.0.js"></script>


  </body>

</html>

My file templates/cassiopeia_lolo/admin/style.php

<?php

define('_JEXEC', 1);
define('JPATH_BASE', __DIR__ . '/../../..');

require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';

// Boot the DI container.
$container = \Joomla\CMS\Factory::getContainer();

// UPDATED alias the session service key to the web session service.
$container->alias('session.web', 'session.web.site')
    ->alias('session', 'session.web.site')
    ->alias('JSession', 'session.web.site')
    ->alias(\Joomla\CMS\Session\Session::class, 'session.web.site')
    ->alias(\Joomla\Session\Session::class, 'session.web.site')
    ->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');

$app        = $container->get(\Joomla\CMS\Application\SiteApplication::class);
//$myTemplate = $app->getTemplate(true);
//$params     = $myTemplate->params;

header("Content-Type:text/css; charset=UTF-8");
header("Cache-Control:must-revalidate");

?>
:root{
--lolocolor: <?php echo $params->get('backgroundcolor');?>;
}

templates/cassiopeia_lolo/templateDetails.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="template" client="site">
  <name>cassiopeia_lolo</name>
  <version>1.0</version>
  <creationDate>septembre 2022</creationDate>
  <author>Super Utilisateur</author>
  <authorEmail>contact@velorution-toulouse.org</authorEmail>
  <copyright>(C) 2017 Open Source Matters, Inc.</copyright>
  <description>TPL_CASSIOPEIA_XML_DESCRIPTION<![CDATA[<link rel="stylesheet" type="text/css" href="../../templates/cassiopeia_lolo/admin/style.php" />]]></description>
  <positions>
    <position>Header</position>
    <position>Nav</position>
    <position>Banner</position>
    <position>Component</position>
    <position>Sidebar</position>
    <position>Footer</position>

  </positions>
  <config>
    <fields name="params">
        <fieldset name="advanced" addfieldpath="/administrator/components/com_apercu/models/fields">
        
        
        <field name="Aperçu" type="Apercu" label="TPL_CASSIOPEIA_APERCU" description="TPL_CASSIOPEIA_APERCU_DESC"/>

        <field name="backgroundcolor" type="color" default="#eee" format="rvba"
          label="TPL_CASSIOPEIA_COLOR_HEADER"
        description="TPL_CASSIOPEIA_FIELD_HEADER_BACKGROUND_COLOR_DESC" /> 
        <field name="logocolor" type="color" default="#eee" format="rvba"
          label="TPL_CASSIOPEIA_LOGO_COLOR"
        description="TPL_CASSIOPEIA_LOGO_COLOR_DESC" />
        <field name="logocolor2" type="color" default="#eee" format="rvba"
          label="TPL_CASSIOPEIA_LOGO_COLOR2"
        description="TPL_CASSIOPEIA_LOGO_COLOR2_DESC" />
        
        
        <field name="brand" type="radio" label="TPL_CASSIOPEIA_BRAND_LABEL" default="1" layout="joomla.form.field.radio.switcher" filter="boolean">
          <option value="0">JNO</option>
          <option value="1">JYES</option>
        </field>

        <field name="logoFile" type="media" default="" label="TPL_CASSIOPEIA_LOGO_LABEL" showon="brand:1"/>
        <field name="siteTitle" type="text" default="" label="TPL_CASSIOPEIA_TITLE" filter="string" showon="brand:1"/>
        <field name="siteDescription" type="text" default="" label="TPL_CASSIOPEIA_TAGLINE_LABEL" description="TPL_CASSIOPEIA_TAGLINE_DESC" filter="string" showon="brand:1"/>
        <field name="useFontScheme" type="groupedlist" label="TPL_CASSIOPEIA_FONT_LABEL" default="0">
          <option value="0">JNONE</option>
          <group label="TPL_CASSIOPEIA_FONT_GROUP_LOCAL">
            <option value="media/templates/site/cassiopeia/css/global/fonts-local_roboto.css">Roboto (local)</option>
          </group>
          <group label="TPL_CASSIOPEIA_FONT_GROUP_WEB">
            <option value="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@100;300;400;700&amp;display=swap">Fira Sans (web)</option>
            <option value="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@100;300;400;700&amp;family=Roboto:wght@100;300;400;700&amp;display=swap">Roboto + Noto Sans (web)</option>
          </group>
        </field>
        <field name="noteFontScheme" type="note" description="TPL_CASSIOPEIA_FONT_NOTE_TEXT" class="alert alert-warning"/>
        <field name="colorName" type="filelist" label="TPL_CASSIOPEIA_COLOR_NAME_LABEL" default="colors_standard" fileFilter="^custom.+[^min]\.css$" exclude="^colors.+" stripext="true" hide_none="true" hide_default="true" directory="media/templates/site/cassiopeia/css/global/" validate="options">
          <option value="colors_standard">TPL_CASSIOPEIA_COLOR_NAME_STANDARD</option>
          <option value="colors_alternative">TPL_CASSIOPEIA_COLOR_NAME_ALTERNATIVE</option>
        </field>
        <field name="fluidContainer" type="radio" layout="joomla.form.field.radio.switcher" default="0" label="TPL_CASSIOPEIA_FLUID_LABEL">
          <option value="0">TPL_CASSIOPEIA_STATIC</option>
          <option value="1">TPL_CASSIOPEIA_FLUID</option>
        </field>
        <field name="stickyHeader" type="radio" label="TPL_CASSIOPEIA_STICKY_LABEL" layout="joomla.form.field.radio.switcher" default="0" filter="integer">
          <option value="0">JNO</option>
          <option value="1">JYES</option>
        </field>
        <field name="backTop" type="radio" label="TPL_CASSIOPEIA_BACKTOTOP_LABEL" layout="joomla.form.field.radio.switcher" default="0" filter="integer">
          <option value="0">JNO</option>
          <option value="1">JYES</option>
        </field>
      </fieldset>
    </fields>
  </config>
  <files>
    <filename>templateDetails.xml</filename>
  </files>
  <media folder="media" destination="templates/site/cassiopeia_lolo">
    <folder>css</folder>
    <folder>js</folder>
    <folder>images</folder>
    <folder>html</folder>
    <folder>scss</folder>
  </media>
  <inheritable>0</inheritable>
  <parent>cassiopeia</parent>
</extension>
LoloTool
  • 11
  • 1

0 Answers0