cotonti.com : XTemplate 2.0 https://www.cotonti.com Последние сообщения в теме Cotonti en Mon, 06 Oct 2025 08:29:48 -0000 musiconly
but this did
   1. <!-- IF {COMMENTS_ROW_AUTHORID} == {PHP.pag.page_ownerid} --> some code here <!-- ENDIF -->

i was so close :-) thanks Trust! :-)]]>
ср, 29 июл 2009 22:29:59 -0000
Trustmaster
<!-- IF {COMMENTS_ROW_AUTHOR} == {PHP.pag.page_ownerid} --> some code here <!-- ENDIF -->
]]>
ср, 29 июл 2009 21:53:25 -0000
musiconly
trying to do something with comments, couldn't figure it out.

Since you can't use page.tpl tags in comments.tpl tags this condition:

<!-- IF {COMMENTS_ROW_AUTHOR} == {PAGE_AUTHOR} --> some code here <!-- ENDIF -->

isn't working.

So i need to find a global tag.

Is there any tag which will act like $usr['isowner'] or $usr['isadmin']. I tried {PHP.usr.isadmin}, {PHP.pag.page_owner} (don't know if that codes are even "the right" ones).

Basically, what I'm trying to accomplish is different display of comment if the comment author is also the author(owner) of the page they're commenting. You can see this a lot on WP powered sites.]]>
ср, 29 июл 2009 19:17:59 -0000
tensh
Thanks for guidelines, now my conditional tags will be better :)]]>
ср, 29 июл 2009 18:21:00 -0000
Trustmaster
  • You must not use parenthesis () in conditions
  • Do not quote the integers
  • Equal is == not =
  • If it is not in users.profile.tpl, then {PHP.usr.profile.user_maingrp} is not valid because it is defined only in users.profile.inc.php. For any template file you should use {PHP.usr.maingrp} instead which is global.
  • ]]>
    чт, 23 июл 2009 19:34:10 -0000
    tensh
    I tried without (), with more () and with '' quotes, still nothing. Help?

    <li><a href=https://www.cotonti.com/"index.php">Home</a></li>
    <!-- IF ({PHP.usr.profile.user_maingrp} = "4" OR {PHP.usr.profile.user_maingrp} = "6") -->
    <li><a href=https://www.cotonti.com/"plug.php?e=link">Lista 1</a></li>
    <!-- ENDIF -->
    <!-- IF ({PHP.usr.profile.user_maingrp} = "4" OR {PHP.usr.profile.user_maingrp} = "7" OR {PHP.usr.profile.user_maingrp} = "6") -->
    <li><a href=https://www.cotonti.com/"plug.php?e=link2">Lista 2</a></li>
    <!-- ENDIF -->
    <!-- IF ({PHP.usr.profile.user_maingrp} = "4" OR {PHP.usr.profile.user_maingrp} = "9" OR {PHP.usr.profile.user_maingrp} = "6") -->
    <li><a href=https://www.cotonti.com/"plug.php?e=link3">Lista 3</a></li>
    <!-- ENDIF -->
    ]]>
    чт, 23 июл 2009 18:48:35 -0000
    Trustmaster ср, 15 июл 2009 01:36:04 -0000 tensh вт, 14 июл 2009 21:36:44 -0000 Trustmaster пн, 13 июл 2009 23:58:43 -0000 tensh http://www.yot.nazwa.pl/header.zip]]> пн, 13 июл 2009 22:46:22 -0000 Trustmaster
    Could you give those templates with BOM to test?]]>
    пн, 13 июл 2009 21:24:43 -0000
    tensh
    Warning: mb_strpos() [function.mb-strpos]: Offset not contained in string in /home/sth/site/system/xtemplate.class.php on line 85
    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 27132033 bytes) in /home/sth/site/system/xtemplate.class.php on line 287

    Edit:

    Hmm, the same happens in other plugins... now I'm not that sure what might be the cause. Other plugin parts? Or something with ajax?

    Edit2:

    Xtemplate sometimes acts unstable... like it displays the beginning of page.tpl like this:
    <!-<div class="mboxHD"><a href=https://www.cotonti.com/"news/">News</a>
    It's because it doesn't accept foreign letters in ANSI coding as well.
    Also, BOM-removing code doesn't work, header.tpl with BOM mark is not loaded at all.
    UTF-8 tpls without BOM are displayed correctly. The same with ANSI coded tpl without special letters.]]>
    пн, 13 июл 2009 16:56:53 -0000
    Trustmaster пн, 13 июл 2009 15:35:08 -0000 tensh

    Correct tpl:

    <!-- BEGIN: POLL_VIEW -->
    {POLL_FORM_BEGIN}
    <table>
    <!-- BEGIN: POLLTABLE -->
    <tr>
    	<td><label>{POLL_INPUT}{POLL_OPTIONS}</label></td>
    </tr>
    <!-- END: POLLTABLE -->
    <tr>
    	<td>{POLL_FORM_BUTTON}</td>
    </tr>
    </table>
    {POLL_FORM_END}
    <!-- END: POLL_VIEW -->
    
    
    <!-- BEGIN: POLL_VIEW_VOTED -->
    <table style="width:100%;">
    <!-- BEGIN: POLLTABLE -->
    <tr>
    	<td>{POLL_OPTIONS}</td>
    	<td align="right">{POLL_PER}% ({POLL_COUNT})</td>
    </tr>
    <tr>
    	<td colspan="2" align="right">
    		<div style="width:180px; ">
    			<div class="bar_back">
    				<div class="bar_front" id="pr_{POLL_PER}"></div>
    			</div>
    		</div>
    	</td>
    </tr>
    <!-- END: POLLTABLE -->
    </table>
    <script type="text/javascript">
    	function anim(){
    		$(".bar_front").each(function(){
    			var percentage = Math.floor(($(this).attr("id").replace('pr_','')*180)/100)+'px';
    			if ($(this).attr("id")!=""){$(this).css({width:"0"}).animate({width: percentage}, "slow");}
    			$(this).attr("id","");
    		});
    	}
    	anim();
    </script>
    <div><div id="pfsBack">{PHP.skinlang.page.Date} {POLL_SINCE_SHORT}</div> {PHP.skinlang.ratings.Votes} {POLL_VOTERS} </div>
    <!-- END: POLL_VIEW_VOTED-->
    
    
    <!-- BEGIN: POLL_VIEW_DISABLED -->
    <table>
    <!-- BEGIN: POLLTABLE -->
    <tr>
    	<td>{POLL_OPTIONS}</td>
    </tr>
    <!-- END: POLLTABLE -->
    <tr>
    	<td>{PHP.L.rat_registeredonly}</td>
    </tr>
    </table>
    <!-- END: POLL_VIEW_DISABLED -->
    
    <!-- BEGIN: POLL_VIEW_LOCKED -->
    <table style="width:100%;">
    <!-- BEGIN: POLLTABLE -->
    <tr>
    	<td>{POLL_OPTIONS}</td>
    	<td align="right">{POLL_PER}% ({POLL_COUNT})</td>
    </tr>
    <tr>
    	<td colspan="2" align="right">
    		<div style="width:180px; ">
    			<div class="bar_back">
    				<div class="bar_front" style="width:{POLL_PER}%;"></div>
    			</div>
    		</div>
    	</td>
    </tr>
    <!-- END: POLLTABLE -->
    </table>
    <div><div id="pfsBack">{PHP.skinlang.page.Date} {POLL_SINCE_SHORT}</div> {PHP.skinlang.ratings.Votes} {POLL_VOTERS} </div>
    <!-- END: POLL_VIEW_LOCKED -->
    
    
    <!-- BEGIN: INDEXPOLLS -->
    <!-- BEGIN: POLL -->
    <h5><a href=https://www.cotonti.com/"{IPOLLS_URL}">{IPOLLS_TITLE}</a></h5>
    {IPOLLS_FORM}
    <div style="text-align: right;">{PHP.skinlang.comments.Comment} {IPOLLS_COMMENTS}</div>
    <hr />
    <!-- END: POLL -->
    
    <!-- BEGIN: ERROR -->
    <div class="error">{IPOLLS_ERROR}</div>
    <!-- END: ERROR -->
    
    <p style="text-align: center;">{IPOLLS_ALL}</p>
    <!-- END: INDEXPOLLS -->
    

    Edit:
    Also, I noticed that " in articles is escaped (\"Administrators\") - is it correct behaviour or should it be exchanged with html equivalent of this sign? (it doesn't have anything to do with X-Template, though)]]>
    пн, 13 июл 2009 15:05:29 -0000
    Trustmaster
    <!-- IF {PHP.urr.user_extra5} != '' -->
    ]]>
    пн, 13 июл 2009 13:23:08 -0000
    SunChase Вставил в тпл стандартный
    <!-- IF {PHP.urr.user_extra5} !='' -->
    в середине которого должно было выводится значение этого поля если оно заполнено.
    По задумке в него должна была вписыватся ссылка формата <a href=https://www.cotonti.com/"">... .Предыдущий ХТемплейт что у меня стоял,как в результате длительных поисков выяснилось ,что он выдавал ошибку конкретно изза ковычек (" ") после href=https://www.cotonti.com/.

    Вторая проблема состояла в том,что ХТемплейт реагировал на тег USERS_DETAILS_ICQ (Показывает в page.details номер аськи + значёк\кнопку на веб профиль на самом сайте айсикью).Ошибка аналогичная той,что и в первом случае.

    Сама ошибка в обоих случаях писала какойто эрор под шапкой(уже непомню какой - кустарными методами пришлось решать проблему) и вообще невыводило то что должно было выводить по условию.]]>
    пн, 13 июл 2009 08:21:35 -0000
    Trustmaster пн, 13 июл 2009 06:36:31 -0000 SunChase I had a problem using the previos XTemplate:
    When i put an Extrafield in "If the field isnt empty - show" and entered in that field a link
    ,in started to give an error on <a href=https://www.cotonti.com/"...">.

    The second problem was with the ICQ field in the user.details.It started to work only after i put in the "If" the direct name of the field(not stationar tag)

    Have this things been fixed in this version?]]>
    пн, 13 июл 2009 03:03:54 -0000
    Trustmaster
    UPDATE:
    • Added BOM removal for UTF-8 with BOM
    • Added variable negation in logic blocks
    • Added support for multi-block TPL files (with multiple root blocks)

    And found that XTemplate 1.0 was not space sensitive, so be careful.]]>
    вс, 12 июл 2009 23:52:26 -0000
    GHengeveld вс, 12 июл 2009 18:55:31 -0000 tensh For testers, be sure to have all tpl files saved in ANSI coding, in case of UTF-8 Xtemplate 2.0 might act differently because of UTF-8 BOM mark at the beginning of a file (Sometimes I'm careless and accidently save tpls as UTF-8).]]> вс, 12 июл 2009 18:21:10 -0000 Trustmaster вс, 12 июл 2009 00:42:26 -0000 tensh
    By the way, does it mean that a previous Xtemplate didn't use strict syntax and allowed for various space and case-insensitive statements?]]>
    сб, 11 июл 2009 19:57:53 -0000
    Trustmaster
    It is almost backwards compatible with original XTemplate, but it only implements those features that we use in Cotonti. This principle is called minimalistic. Here is what it supports:
    • Blocks and original XTemplate flow control
    • Variable substitutions (aka tags)
    • Logical blocks (if/else/endif)
    • Inclusion of other templates within templates with FILE
    Here is what it does not support:
    • Callbacks
    • Customizable syntax

    Another principle is strict. It means that:
    • Statements are case sensitive. It will understand BEGIN but not begin:
      <!-- BEGIN: TEST -->
          <div>This is a valid block!</div>
      <!-- END: TEST -->
      
      <!-- begin: test -->
          <div>This block is invalid!</div>
      <!-- end: test -->
      
    • Spaces matter, especially in logical statements. There must be spaces in statements at correct positions, e.g.
      <!-- IF {PHP.something} > 0 -->
          <div>This is a valid block!</div>
      <!-- ENDIF -->
      
      <!--IF{PHP.something}>0-->
          <div>This block is invalid!</div>
      <!--ENDIF-->
      
    • Logical expressions are limited functionality. Supported logical operators are: AND, OR (AND has higher priority). Parenthesis is not supported. Supported comparison operators are: ==, !=, <, >, <=, >=, !. First operand of comparison must be a template variable e.g. {PHP.my.test}. Second operand may be a template variable, a number or a quoted string. Example:
      <!-- IF {USER_DETAILS_NAME} = 'Mark' AND {PHP.g} >= 6 OR !{PHP.error_string} -->
          <div>The expression is true!</div>
      <!-- ELSE -->
          <div>The expression is false!</div>
      <!--END:TEST-->
      
    • Nested logical blocks are not supported, e.g.
      <!-- IF {PHP.foo} = 'test' -->
          <!-- IF {PHP.bar} -->
              <div>This block is invalid!</div>
          <!-- ENDIF -->
      <!-- ENDIF -->
      
    • Template blocks inside of logical blocks are not supported, e.g.
      <!-- IF {PHP.foo} = 'test' -->
          <!-- BEGIN: BAR -->
              <div>This block is invalid!</div>
          <!-- END: BAR -->
      <!-- ENDIF -->
      

    The third principle is fast. XTemplate 2.0 is much faster than original XTemplate 1.0, literally 2 times faster. Benchmarks demonstrate 5-35% RPS (requests per second) increase for entire pages after upgrade.

    The fourth principle is lightweight. The code is 4 times smaller.

    What's new in XTemplate 2.1:
    1. Block names are no more space sensitive, so it's compatible with XTemplate 1.0
    2. Support for {FILE "path/to/template.tpl"}
    3. Disk cache for better performance
    ]]>
    сб, 11 июл 2009 19:47:51 -0000