This topic is locked

Template language

10/7/2013 4:46:46 AM
PHPRunner General questions
W
wpl author

Hi all,
this is a question I can't find an answer for in the documentation: how would I test for the existence of a variable in a template file?

I know I would test for true or false (1 or 0) like so:



##if @variable##


or for a certain value like:



##if @variable=="ID"##


But how would I test if @variable exists at all?
Thanks

Sergey Kornilov admin 10/7/2013

You cannot test the variable existence.
I'd like to add that you can have better luck if you explain what you trying to achieve as opposed to how you trying to achieve it.

W
wpl author 10/7/2013



You cannot test the variable existence.
I'd like to add that you can have better luck if you explain what you trying to achieve as opposed to how you trying to achieve it.


Sergey,
thanks. What I would like to achieve is what Delphiprog has been describing in this thread:
http://http://www.asprunner.com/forums/topic/4155-session-variables-with-two-apps-running/,
ie using strProjectName as session_name. But strProjectName is only defined in the phpr file if you are starting from a template. In an empty project, this will throw an error upon building. I would like to avoid having to manually insert



<m_strProjectName></m_strProjectName>


(most time empty) in every project. Hence my question how to test for the existance of this var in dbcommon.php.
Thanks

Sergey Kornilov admin 10/7/2013

Thanks, I understand the idea - you need to use some unique value so different projects do not share sessions.
How's about this then:

@session_cache_limiter("none");

@session_name(str_replace(" ", "", "##@BUILDER.m_lastDbSyncTime##"));

@session_start();
W
wpl author 10/7/2013



Thanks, I understand the idea - you need to use some unique value so different projects do not share sessions.
How's about this then:

@session_cache_limiter("none");

@session_name(str_replace(" ", "", "##@BUILDER.m_lastDbSyncTime##"));

@session_start();



Sergey,
thanks for this suggestion. I will give it a try. One flaw I can think of is that I can't tell which session file belongs to which app when I want to analyse the session in an editor.

Sergey Kornilov admin 10/7/2013

There are others ways of doing this, I just suggested the simplest one.
Btw, what "analyse the session in an editor" means?