We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32982
    • 674 Posts
    sorry for read later post too quikly and for ask whithout investigate the code but in my reaad attach some cuestions
    is easy to implemnt?
    the examples in top dont show my bad interpretation of the post
    where could be helper for a snippet developement?
    or for a designer site usage,
    i realy like the modx templating sistem and dont undertand how it help?
    for the designer is more flexible than put a html template and calls to snipets?
    is good for make multilingual snippets?
    thanks
      Jabiertxof (formerly XYZVISUAL)
      My bussines: http://marker.es
      https://www.youtube.com/user/jabiertxof/videos
      • 18219
      • 826 Posts
      Hi,

      I would like to know if the library will change. We use it to improve the snippet MaxiGallery. But for the moment, the instructions contained in chunktpl are insufficient. I will take an example for good to render comprehensible myself.
      We would like to have the following code:
      <a href="{+PrevPicLink+}">{+TextPrevious+}</a> | <a href="{+IndexLink+}">{+TextIndex+}</a> | <a href="{+NextPicLink+}">{+TextNext+}</a>
      

      But when there is not any preceding image, we would like the code:
      {+TextPrevious+}| <a href="{+IndexLink+}">{+TextIndex+}</a> | <a href="{+NextPicLink+}">{+TextNext+}</a>
      

      Or if there is not any following image, we would like the code:
      <a href="{+PrevPicLink+}">{+TextPrevious+}</a> | <a href="{+IndexLink+}">{+TextIndex+}</a> | {+TextNext+}
      

      To carry out that, we would need more instructions like:
      {~if condition~} {~elseif~} {~else~} {~end~}
      {~for condition~} {~end~}
      {~while condition~} {~end~}
      etc.
      

      Our example would become:
      {~if previousPic~} <a href="{+PrevPicLink+}">{+TextPrevious+}</a> 
      {~else~} {+TextPrevious+} 
      {~end~}
       | <a href="{+IndexLink+}">{+TextIndex+}</a> | 
      {~if nextPic~}<a href="{+NextPicLink+}">{+TextNext+}</a>
      {~else~} {+TextNext+} 
      {~end~}
      

      What do you think about it?

      Edit :I forgot to say: I modify the snippet MaxiGallery in agreement with Doze.
        Marc
        I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
        • 7923
        • 4,213 Posts
        In the meanwhile before Wendy replies to say how this really goes, I’ll take a stab at it smiley

        This is just a hunch, as I haven’t tried the chunktpl yet, but I guess the conditionals goes something like this (Marc, refer to the code around line 599 of maxigallery.php what you sent to me earlier):

        <?php
        	$next_pic = $modx->makeUrl($modx->documentIdentifier, '', "&pic=".$pics[$i+1]['id'].$next_pic_querystr);
        	$previous_pic = $modx->makeUrl($modx->documentIdentifier, '', "&pic=".$pics[$i-1]['id'].$previous_pic_querystr);
        
        	//build back to index link
        	if($_REQUEST['from_id']){
        		$back_to_index = $modx->makeUrl($_REQUEST['from_id'], '', '');
        	}else if($mg->mgconfig['is_target']==true && $_REQUEST['gal_id']){
        		$back_to_index = $modx->makeUrl($_REQUEST['gal_id'], '', '');
        	}else{
        		$back_to_index = $modx->makeUrl($modx->documentIdentifier, '', '');
        	}
        
        	//if has previous image
        	if($i+1!=1){
        		$hasPervious = true;
        	}else{
        		$hasPervious = false;
        	}
        
        	if(isset($index_suffix)) {
        		$strings['index'] .= " ".$index_suffix;
        	}
        		
        	//if has more images
        	if($i+1!=count($pics)){
        		$hasNext = true;
        	}else{
        		$hasNext = false;
        	}
        
        	$conditionData['PrevLink'] = $previous_pic;
        	$conditionData['NextLink'] = $next_pic;
        	$conditionData['IndexLink'] = $back_to_index;
        	$conditionData['PrevText'] = $strings['previous'];
        	$conditionData['NextText'] = $strings['next'];
        	$conditionData['IndexText'] = $strings['index'];
        	$tplObject->outputCondition($fname.'HasPrevious', $hasPervious, $conditionData, $conditionData);
        	$tplObject->outputCondition($fname.'HasNext', $hasNext, $conditionData, $conditionData);
        ?>


        And this should go with a template like this, i guess..

        {[=TplPart HasPrevious_True=]}
        <a href="{+PrevLink+}">{+PrevText+}</a> 
        {[=TplPart HasPrevious_False=]}
        {+PrevText+} 
        
        | {+IndexText+} |
        
        {[=TplPart HasNext_True=]}
        <a href="{+NextLink+}">{+NextText+}</a>
        {[=TplPart HasNext_False=]}
        {+NextText+}
        


        And the looping in the simplest form would go something like:

        <?php
        
        	$pics=$modx->getIntTableRows("*", $mg->mgconfig['gtable'], "gal_id='" . $pageinfo['id'] . 
        	"'",$mg->mgconfig['order_by'],$mg->mgconfig['order_direction']);
        
        	
        	// Parse body template with loop from arrayData
        	for($i = 0; $i < count($pics); $i++) {
        		$pic = $pics[$i];
        		$file = $path_to_gal . $pic['filename'];
        		$tn_file = $path_to_gal . "tn_" . $pic['filename'] ;
        		
        		if(isset($picture_target) && $picture_target != "") {
        			$link = $modx->makeUrl($picture_target, '', "&gal_id=".$pageinfo['id']."&pic=".$pic['id']);
        		}else{
        			$link = $modx->makeUrl($modx->documentIdentifier, '', "&pic=".$pic['id']);
        		}
        		$title = htmlentities(stripslashes($pic['title']),ENT_QUOTES,$mg->mgconfig['use_charset'])
        		$descr = htmlentities(stripslashes($pic['descr']),ENT_QUOTES,$mg->mgconfig['use_charset'])
        
        		$arrayData[$i]['ThumbUrl'] = $tn_file;
        		$arrayData[$i]['PicLink'] = $link;
        		$arrayData[$i]['PicTitle'] = $title;
        		$arrayData[$i]['PicDescr'] = $descr;
        		$arrayData[$i]['PicDate'] = $pic['date'];
        	}
        	$output .= $tplObject->outputRepeater('Loop', $arrayData);
        ?>
        


        And this with template:

        {[=TplPart Loop_Header=]}
        <div><p>
        {[=TplPart Loop_Item1=]}
        <a href="{+PicLink+}" title="{+PicTitle+}" alt="{+PicDate+}"><img src="{+ThumbUrl+}" alt="{+PicDate+} - {+PicTitle+}" />
        </a>
        {[=TplPart Loop_Item2=]}
        <a href="{+PicLink+}" title="{+PicTitle+}" alt="{+PicDate+}"><img src="{+ThumbUrl+}" alt="{+PicDate+} - {+PicTitle+}" />
        </a>
        {[=TplPart Loop_Item3=]}
        <a href="{+PicLink+}" title="{+PicTitle+}" alt="{+PicDate+}"><img src="{+ThumbUrl+}" alt="{+PicDate+} - {+PicTitle+}" />
        </a>
        {[=TplPart Loop_Separator=]}
        </p><p>
        {[=TplPart Loop_Footer=]}
        </p></div>
        


        That would output the gallery overview like:

        <div>
        <p>image 1 ... image 2 ... image 3</p>
        <p>image 4 ... image 5 ... image 6</p>
        </div>

        But ofcourse the gallery overview code will be more complicated of this, because of the paging and different display/embedtype features..

        I don’t know that will these actually work, but I guess it something like that. Try it.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 18219
          • 826 Posts
          Before Wendy replies, I like replies to Doze :

          Here the template that I propose to use:
          {[=TplPart Manager_True=]}
          	<div>{+Manager+}</div>
          {[=TplPart Thumb=]}
          	<div>{+Title+}</div>
          	<div style="text-align:center;">
          	<p>{+Previous+} | {+Index+} | {+Next+}</p>
          	<p>{+Thumbnails+}</p>
          	</div>
          {[=TplPart Picture=]}
          	<div>{+Title+}</div>
          	<div style="text-align:center;">
          	<p>
          		{~if HasPrevious~}
          			{~<a href="{+PrevPicLink+}">{+PrevText+}</a> ~}
          		{~else~}
          			{+PrevText+}
          		{~end~}
          		 | <a href="{+IndexLink+}">{+IndexText+}</a> | 
          		{~if HasNext~}{~<a href="{+NextLink+}">{+NextText+}</a>~}
          		{~else~} {+NextText+} 
          		{~end~}
          	</p>	
          	<p>{+PicNumber+}</p>
          	<span class="galleria">{+Picture+}</span>
          	<p><b>{+ImageTitle+}</b></p>
          	<p>{+ImageDesc+}</p>
          	</div>
          

          It appears simple to to me of comprehension and present the advantage of separating the various parts of the template well (TplPart Manager, TplPart Thumb, TplPart Picture). The variable {+Picture+} or {+ImageTitle+} or {+ImageDesc+} belongs to the part of the template “Picture”.

          If I take again your proposal, veiled what that gives for a template:
          {[=TplPart Manager_True=]}
          	<div>{+Manager+}</div>
          {[=TplPart Thumb=]}
          	<div>{+Title+}</div>
          	<div style="text-align:center;">
          	<p>{+Previous+} | {+Index+} | {+Next+}</p>
          	<p>{+Thumbnails+}</p>
          	</div>
          {[=TplPart Picture=]}
          	<div>{+Title+}</div>
          	<div style="text-align:center;">
          
          {[=TplPart HasPrevious_True=]}
          <a href="{+PrevLink+}">{+PrevText+}</a> 
          {[=TplPart HasPrevious_False=]}
          {+PrevText+} 
          
          | {+IndexText+} |
          
          {[=TplPart HasNext_True=]}
          <a href="{+NextLink+}">{+NextText+}</a>
          {[=TplPart HasNext_False=]}
          {+NextText+}
          
          	<p>{+PicNumber+}</p>
          	<span class="galleria">{+Picture+}</span>
          	<p><b>{+ImageTitle+}</b></p>
          	<p>{+ImageDesc+}</p>
          	</div>
          

          The variables {+Picture+} or {+ImageTitle+} or {+ImageDesc+} do not form any more part of the template “Picture” but to "HasNext_False" (or other, if add instruction {[=TplPart ...=]} before <p>{+PicNumber+}</p>).
          In other words, if the end-user wishes to modify posting, the code of the snippet must be also to modify to take into account the order. It’s not a simple solution.

          This is why I propose to add instructions in the library chunktpl: to have of advantage of flexibility.
            Marc
            I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
            • 32241
            • 1,495 Posts
            Hi guys,

            It’s almost a month, since I lost all the benefit in US. I have a dialup connection here, and it runs really slow.

            Anyway, the implementation that doze showed in his reply is the correct way to use the library.
            To understand more about the library, it’s actually just a simple templating library to replace the use multiple chunks as atemplate like what we have right now in some of our snippets. So all that separator tag like this {[=TplPart Picture=]} will work as a divider to divide the template into several part that are accessible as several small templates to be processed further.

            To solve the conditional tag and looping, I implement it as simple as possible. It’s basically just using the core system to fetch certain template part and combine it on the programming side. So if you see it closely, the looping is actually just a combination of several parts, and the same thing with conditional. So if you understand about the core system, looping and conditional is not part of the core, it’s just a helper method provided inside the class to help programmers in doing most of their templating. The core template itself is just fetching template from files/chunks, separate the template into several small templates, parsed the template by combining a specific template part with the stored variables inside the class object. That’s the whole idea.

            When talking about template, it’s actually quite a broad subject. We can even use raw PHP and call it as a template, while some people prefer [*var_name*] or {var_name}. No matter what, all that I can do is just set the limit, on how flexible I want the library to be. So when I built this library, I kept the idea of simplicity. I want this template library to act similar with native templating system that we have in MODx. So everything is being defined already by the system that you built. Lets assume, instead of allowing designer to decided whether to do if conditional tag or plain variable output, the developer already set the rule that the designer have to use conditional template on this part, while on the other part it will be just a plain variable output. So the designer will have a really clarified template that he can modify further, but still keeping the simplicity for the designer.

            So, if you guys decide to take the library and expand it further, go ahead, and include those as a native class in maxigallery and modify it, I will be glad to see those code being embeded and use on maxigallery.

            PS: My vision will be to let every snippet have their own themes being shipped as a default, but still allowing user to create a new theme using chunk. It’s achieveable with this class. Instead of reading the template from file, you can ask the class to read the template from chunk. Hope it will be a good tips.

            Sincerely,
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 18219
              • 826 Posts
              Hi,

              I modified a library for integrate a conditionnal tag and looping. I want that implementation has simple as possible.
              In the code of library, changed the function ’parseTpl’ by this code :
              	// Parse given template with template variables
              	function parseTpl($tpl) {
              		$tpl = strtolower(trim($tpl));
              		if(isset($this->chunkTplData[$tpl]['Template']) && $this->chunkTplData[$tpl]['Template'] != NULL) {
              			$output = $this->chunkTplData[$tpl]['Template'];
              			// Match all instructions
              			$output = $this->parseInstruction($tpl, $output);
              			// Match all template variables
              			preg_match_all('~\{\+(.*?)\+\}~', $output, $matches);
              			// Loop through the matching template variables
              			for($i = 0; $i < count($matches[1]); $i++) {
              				$rawVarName = $matches[1][$i];
              				// Parse variable
              				if(strpos($rawVarName, ';') < 1) {
              					$value = $this->chunkTplData[$tpl]['Data'][strtolower(trim($rawVarName))];
              					if(isset($value) && $value != NULL)
              						$output = str_replace('{+'.$rawVarName.'+}', $value, $output);
              					else
              						$output = str_replace('{+'.$rawVarName.'+}', '', $output);
              				}
              				// Parse variable with function
              				else {
              					$tempVar = explode(';', $rawVarName);
              					if(count($tempVar) > 1) {
              						$value = $this->chunkTplData[$tpl]['Data'][strtolower(trim($tempVar[0]))];
              						$function = strtolower(trim($tempVar[1]));
              						$param = array();
              						for($i = 2; $i < count($tempVar); $i++) {
              							$tempParam = split(':', $tempVar[$i]);
              							if(is_array($tempParam) && count($tempParam) >= 1)
              								$param[$tempParam[0]] = (isset($tempParam[1]) ? $tempParam[1] : NULL);
              						}
              						if(is_callable(array(get_class($this), $function)))
              							$output = str_replace('{+'.$rawVarName.'+}', call_user_func(array(get_class($this), $function), $value, $param), $output);
              						else
              							$output = str_replace('{+'.$rawVarName.'+}', $value, $output);
              					}
              					else
              						$output = str_replace('{+'.$rawVarName.'+}', '', $output);
              				}
              			}
              			// Return output
              			return $output;
              		}
              		return '';
              	}
              


              Add this function in the library:
              	function parseInstruction ($tpl, $output){
              		// Match all instructions
              		preg_match_all('~(\{\~)(.*?)(\~\})~', $output, $matches);
              		$elemt=$matches;
              		// Init variables
              		$level=0;
              		$openInst[$level]='';
              		// Loop through the matching instructions
              		for($i = 0; $i < count($elemt[2]); $i++) {
              			if(strpos(trim($elemt[2][$i]), ' (=') > 1 || (!strpos(trim($elemt[2][$i]), '+}') && !strpos(trim($elemt[2][$i]), '/>') && !strpos(trim($elemt[2][$i]), '</')))
              			{
              				if ($this->debug) echo"Debug >> Inst: <b>".htmlentities($elemt[2][$i])."</b><br />";
              				$typeElemt="Instruction";
              				// Parse instruction
              				if(strpos(trim($elemt[2][$i]), ' (=') > 1){
              					$tempInst=explode(' (=',trim($elemt[2][$i]));
              					if (count($tempInst)>0)	{$inst= $tempInst[0];}					
              				}
              				else{
              					$inst= ($elemt[2][$i]);				
              				}
              				switch ($inst) {
              		            case 'if':
              		            	if ($openInst[$level]!=''){$level++;}
                        				$openInst[$level]='if';
              	            		preg_match_all('~\(\=(.*?)\=\)~', $elemt[2][$i], $matches);
              	            		$rawVarName = $matches[1][0];
              	            		$condition[$level] = $this->chunkTplData[$tpl]['Data'][strtolower(trim($rawVarName))];
              		                break;
              		            case 'elseif':
              		            	if ($openInst[$level]!='if'&&$openInst[$level]!='elseif'){return "Error: The template is not valide";}
              	            		$openInst[$level]='elseif';
              		            	preg_match_all('~\(\=(.*?)\=\)~', $elemt[2][$i], $matches);
              	            		$rawVarName = $matches[1][0];
              	            		$condition[$level] = $this->chunkTplData[$tpl]['Data'][strtolower(trim($rawVarName))];
              		            	break;
              		            case 'else':
              		            	if ($openInst[$level]=='if'||$openInst[$level]=='elseif'){
              		            		$openInst[$level]='else';
              		            		$condition[$level]=!$condition[$level];
              		            	}				
              		            	else {return "Error: The template is not valide";}
              		            	break;
              		            case 'endif':
              		            	if ($openInst[$level]!='if'&&$openInst[$level]!='elseif'&&$openInst[$level]!='else'){return "Error: The template is not valide";}
              						$openInst[$level]='';
              		            	if ($level!=0)$level--;
              		            	break;
              		            case 'switch':
              		            	if ($openInst[$level]!=''){$level++;}
                        				$openInst[$level]='switch';
                        				$closeInst=false;
                        				preg_match_all('~\(\=(.*?)\=\)~', $elemt[2][$i], $matches);
              	            		$rawVarName = $matches[1][0];
              	            		$varSwitch = $this->chunkTplData[$tpl]['Data'][strtolower(trim($rawVarName))];	                	
              		            	break;
              		            case 'case':
              		            	if ($openInst[$level]!='switch'&&$openInst[$level]!='case'){return "Error: The template is not valide";}
              		            	$openInst[$level]='case';
              		            	preg_match_all('~\(\=(.*?)\=\)~', $elemt[2][$i], $matches);
              	            		$value = $matches[1][0];	            		
              	            		$condition[$level]=($varSwitch==$value)?true:false;	            		
              	            		if($condition[$level]){$closeInst=true;}
              		            	break;		         
              		            case 'default':
              		            	if ($openInst[$level]!='switch'&&$openInst[$level]!='case'){return "Error: The template is not valide";}
              		            	$condition[$level]=(!$closeInst)?true:false;
              		            	break;
              		            case 'endswitch':
              		            	if ($openInst[$level]!='switch'&&$openInst[$level]!='case'){return "Error: The template is not valide";}
              						$openInst[$level]='';
              		            	if ($level!=0)$level--;
              		            	break;
              		            default:
              		            	return "Error: The template is not valide. This instruction $inst is not used";
              		            	break;				
              				}
              				
              				if ($this->debug) echo ($condition[$level])?"|---Level: ".$level." >> "."true<br />":"|---Level: ".$level." >> "."false<br />";
              				// Delete instruction
              				if ($this->debug) echo"|---Action >> Delete  Instruction<br /><br />\n";
              				$output = str_replace($elemt[0][$i],'', $output);
              			}
              			else {
              				// Parse Element
              				if ($this->debug) echo"|--- Var: ".htmlentities($elemt[2][$i])."<br />";
              				$typeElemt="Element";
              
              			}
              			// Replace Element
              			if (!$condition[$level] && $typeElemt=="Element"){
              				if ($this->debug) echo"|---Action >> Delete  Element<br /><br />\n";
              				$output = str_replace($elemt[0][$i],'', $output);					
              			}
              			elseif ($condition[$level] && $typeElemt=="Element"){
              				if ($this->debug) echo"|---Action >> <b>Replace  Element</b><br /><br />\n";
              				$output = str_replace($elemt[0][$i],$elemt[2][$i], $output);	
              			}			
              		}
              		// Clean output
              		$output = str_replace('{~','', $output);
              		$output = str_replace('~}','', $output);
              		$output = str_replace("\'","'",$output);
              		
              		// Return output
              		return $output;
              	}
              


              You can modified you template as this:
              {[=TplPart Picture=]}
              	<div>{+Title+}</div>
              	<div style="text-align:center;">
              	<p>
              		{~if (=HasPrevious=)~}{~<a href="{+PrevPicLink+}">{+PrevText+}</a>~}
              		{~else~}{~{+PrevText+}~}
              		{~endif~}
              		 | <a href="{+IndexLink+}">{+IndexText+}</a> | 
              		{~if (=HasNext=)~}{~<a href="{+NextPicLink+}">{+NextText+}</a>~}	
              		{~else~}{~{+NextText+}~}
              		{~endif~}
              	</p>	
              	{~if (=DisplayPicNumber=)~}{~<p>{+PicLabel+}({+PicNumber+}/{+PicTotal+})</p>~}
              	{~endif~}
              	<span class="galleria">
              		{~if (=KeepBigImg=)~}{~
              			{~if (=existBigPic=)~}{~
              				{~switch (=BigImgLinkStyle=)~}
              					{~case (=slidebox=)~}
              						{~<a href="{+LargeImage+}" title="<b>{+ImageTitle+}</b><br />{+ImageDesc+}" rel="lightbox"><img src="{+Picture+}" class="imageview" title="{+ClickToOpenOriginal+}" alt="{+ImageLabelDate+}: {+ImageDate+}" /></a>~}
              					{~case (=lightboxv2=)~}
              						{~<a href="{+LargeImage+}" rel="lightbox" title="<b>{+ImageTitle+}</b><br />{+ImageDesc+}"><img src="{+Picture+}" class="imageview" title="{+ClickToOpenOriginal+}" alt="{+ImageLabelDate+}: {+ImageDate+}" /></a>~}
              					{~case (=popup=)~}
              						{~<a href="javascript:void(0);" onClick="javascript:openWindow(\'{+LargeImage+}\',\'{+ImageTitle+}\',\'{+window_height+}\',\'{+window_width+}\',\'gallery\')"><img src="{+Picture+}" class="imageview" title="{+ClickToOpenOriginal+}" alt="{+ImageLabelDate+}: {+ImageDate+}" /></a>~}
              					{~default~}
              						{~<a href="{+LargeImage+}" rel="external"><img src="{+Picture+}" class="imageview" title="{+ClickToOpenOriginal+}" alt="{+ImageLabelDate+}: {+ImageDate+}" /></a>~}
              				{~endswitch~}
              			~}
              			{~else~}{~<img src="{+Picture+}" class="imageview" alt="{+ImageLabelDate+}: {+ImageDate+}" />~}
              			{~endif~}
              		~}
              		{~else~}{~<a href="{+BackToIndex+}"><img src="{+Picture+}" class="imageview" title="{+ClickToGoBack+}" alt="{+ImageLabelDate+}: {+ImageDate+}" /></a>"~}
              		{~endif~}
              	</span>
              	<p><b>{+ImageTitle+}</b></p>
              	{~if (=DisplayDesc=)~}{~<p>{+ImageDesc+}</p>~}
              	{~endif~}
              	</div>
              


              Is possible to use a conditionnal tag :
              {~if (=condition=)~}{~instructions~}{~elseif (=condition=)~}{~instructions~}{~endif~}
              {~switch (=variable=)~}
              {~case (=value=)~} {~instructions~}

              {~case (=value=)~} {~instructions~}
              {~case (=value=)~} {~instructions~}
              {~default~} {~instructions~}
              {~endswitch~}

              I can to go in holliday for 3 days. I give more explication for used this conditionnals tags.
              I go back tuesday.

              @Wendy : thank for you response. wink
              a+

                Marc
                I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
                • 7923
                • 4,213 Posts
                I have tested Maxigallery developement version where Marc has implemented the changed chunktpl library and it works perfectly... Superb work Marc! The templating is turning out to be more flexible that I even dreamed of it. wink Marc has also done other nice structural changes and code cleaning, the next version will be sweet..

                Also many thanks to Wendy for the chunkTpl library! It’s great to have the whole template in single chunk and ship the default template(s) in files..

                I suggest everyone to try this library, if you are thinking of making templating possible in your snippets!

                Now Marc, tackle the gallery overview looping next! *swopish* (imagine whip lashing) j/k laugh, have a nice holiday! smiley


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 6726
                  • 7,075 Posts
                  Pretty cool stuff indeed, Marc !

                  I had followed the progress of this from a distance, but I like what I am seing there grin
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 30223
                    • 1,010 Posts
                    To each his/her own but I cannot see the real benefit here. Great coding Marc, but aren’t you just introducing an unecessary layer of complexity? I like the idea of combining different ’template’ chunks into one bigger one but when it comes to parsing all kind of logical structures it doesn’t make much sense to me anymore. This is creating an interpreter for another (level of) programming language by an interpreted programming language. Why not just use php for the logic? Am I missing something?
                      • 7923
                      • 4,213 Posts
                      It’s just basic if, else and switch clauses, I think that even new comers can handle that. And there is no need to modify the default template if user is happy with the default layouts. But if they want to change something, I want it to be easy as possible.

                      We could do more static placeholders for example just one place holder for the whole next/prev links section and so on, so that we would not need any logic at the template side, but then it wouldn’t be so flexible. When talking of the Gallery snippet, many users want to customise the output to be very different from original layout, some want links to be just text, some want them to be static pics and some want to be possible to use next pic thumbnail as the link.. change content of the alt and title tags etc.. and when we allow templaters to use conditional statements and looping also, they can make the ouput more usable for the site end users, the visitors. And that is what ultimately matters most.

                      For example when thinking of the next and previous picture links, it’s good to be able to make the link just text (or placeholder image, or whatever), if there is no next/previous image, so it’s more intuitive for the site visitors to use. I don’t care that users of the snippet (site developers) will have to use a little time to learn the system, if/when they want to achieve something special.

                      There has to be some sort of compromise between complexity of use and flexibility of the snippet of course, but as I’m more of a coder than a designer and I support flexibility of the code over ease of use for new users, this is definitely the way to go for me.

                      And we will ofcourse provide good enough templating guide with the snippet to help new users in their troubles.

                      But I understand the point, "why use own code syntax when you could use just php", but it’s not so simple really. To me, the format that Marc has done looks very usable, but I’m open to all suggestions, and I believe Marc is too.



                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."