Zen Cart Logo
Forums / Zen Cart Code Suggestions / Template folder structure

Template folder structure

Views: 64

Results 1 to 2 of 2
21 Apr 2018, 7:55 PM
#1
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Template folder structure

Hi
I was testing something , and I going to move on that path.
Basically it's to have the option to include a "dist" folder at template folder.
Using gulps, node_modules and all that stuff, it turns what's to be uploaded ( or even used in a dedicated server ).
This all can be done by adding

if(file_exists(DIR_WS_TEMPLATES. $template_dir . '/template_info.json')) {
    $tpl_info = DIR_WS_TEMPLATES. $template_dir . '/template_info.json';
    $tpl_info = json_decode(file_get_contents($tpl_info), true);
  }

/**
 * Setting all to be in one folder, separated from node_modules, etc. 
 */
$use_dist_folder = false;
$dist_folder =  $template_info['template_dist_folder']; // would be 'dist'
if (is_dir(DIR_WS_TEMPLATES. $template_dir . '/' .$dist_folder)) { // if dist folder exists
  define('DIR_WS_TEMPLATE', DIR_WS_TEMPLATES . $template_dir . '/' .$dist_folder . '/');
  $use_dist_folder = true;
  // But keeps the $template_dir set for the language files
}else {
/**
 * The actual template directory to use
 */
define('DIR_WS_TEMPLATE', DIR_WS_TEMPLATES . $template_dir . '/');
}

And after getting the proper language

if ($use_dist_folder == true) {
  $template_dir = $template_dir . '/' . $dist_folder . '/';
}

That way is looking for the "dist" folder

On template_select the same thing

while ($file = $dir->read()) {

    if (is_dir(DIR_FS_CATALOG_TEMPLATES . $file) && $file != 'template_default') {
      if (file_exists(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php')
          or
          file_exists(DIR_FS_CATALOG_TEMPLATES . $file . $dist_folder. '/template_info.php')
      ) {
        if(!empty($dist)) {
          require(DIR_FS_CATALOG_TEMPLATES . $file . $dist_folder . '/template_info.php');
        }else {
          require(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php');
        }
        
        $template_info[$file] = array('name' => $template_name,
                                      'version' => $template_version,
                                      'author' => $template_author,
                                      'description' => $template_description,
                                      'screenshot' => $template_screenshot);
      }
    }
  }

So now, I don't have template files mixed with gulp files, and whatever more is used to build the template.
Well, just a idea

23 Apr 2018, 9:17 AM
#2
bebijuteria avatar

bebijuteria

Zen Follower

Join Date:
Feb 2006
Posts:
124
Plugin Contributions:
0

Re: Template folder structure

From Lisbon? Can you send a pm