Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
smarty vars in php...in .tpl
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/08/10 04:27 
Hi
Quite newbie in everything, I need to perform a syntax title check in my tpl. (i'm searching string 'L1' in it) for displaying few songs differently.
I'm in Cobalt skin, in my row song list tpl.
I've tried this:

Code
{if $VAULT_PRICE > 0}
   {php}
   $tit={$SONG_NAME};
echo $tit;
{/php}
but $tit is empty...
How can I get song's title in $tit ?
tx

Back to top
Douglas
Jamroom Team


Joined: 08 Oct 2004
Posts: 6639
Location: Tornado Alley!

Posted: 11/08/10 05:25 
You can use smarty's assign function....


Code
{assign var="tit" value=$SONG_NAME}


http://www.smarty.net/manual/en/language.custom.functions.php#language.function.assign

Hope this helps,
Douglas


_________________
Douglas Hackney
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/08/10 05:39 
If I wasn't a man, I would say : "I love you, Douglas Embarassed ".
Make my day Very Happy !!

Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/08/10 05:45 
Ahemm...
this doesnt work...

Code
 {if $VAULT_PRICE > 0}
  {assign var="tit" value=$SONG_NAME}
   {php}
      echo $tit;
      
      {/php}

why?
To be more precise I need to search a substring in $SONG_NAME, and if I find it, I offset my button 'add to cart' by adding some style="padding...".

Code
if (strstr($tit, 'L1')!==0) {
echo '<input....>;}
else
...etc.

Back to top
Douglas
Jamroom Team


Joined: 08 Oct 2004
Posts: 6639
Location: Tornado Alley!

Posted: 11/08/10 08:05 
You might want to check out the smarty docs ( http://www.smarty.net/manual/en/ )... you can do php inside the {php}{/php} tags, but smarty does the equivalent of php, only it uses tags to do it... for instance, instead of this...


Code
{if $VAULT_PRICE > 0}
  {assign var="tit" value=$SONG_NAME}
   {php}
      echo $tit;
     
      {/php}


you would do this...


Code
{if $VAULT_PRICE > 0}
  {assign var="tit" value=$SONG_NAME}
  {$tit}
{/if}


and instead of this:


Code
if (strstr($tit, 'L1')!==0) {
echo '<input....>;}
else


you might do something like this...


Code
{if strstr($tit, 'L1') !== 0}
<input....>
{else}
something else
{/if}


Hope this helps,
Douglas


_________________
Douglas Hackney
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/08/10 08:28 
I dont really understand Smarty nor Smarty's doc. It's been a while I try, yet!
thx so much Doug. I begin to beguine...

Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/08/10 12:43 
if I may :
I'm trying to extract 'PARIS' from 'PARISL1'

what is the right syntax for it?:

Code
{assign var="pos" value = strpos($tit, 'L1')}

so I get the pos of L1
and after want to grab the $pos left characters of PARISL1

Code
{assign var="NEW_TITLE" value = substr($tit, 0, $pos-1)}


nothing works in the right part of value = ...
I've read the assign function doc you mentionned, try to put it between ' ' but ...
They talk about 'backticks'. Isn't it similar to ' ?

Back to top
Douglas
Jamroom Team


Joined: 08 Oct 2004
Posts: 6639
Location: Tornado Alley!

Posted: 11/08/10 14:44 
You can try this, I'm not sure it will work, but backticks (`) are the same key as the tilde (~) key. And they will need to go around the variable $tit...


Quote:
{assign var="pos" value="strpos(`$tit`, 'L1')"}


Hope this helps,
Douglas


_________________
Douglas Hackney
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/10/10 19:01 
I don't believe you can do that. Can you post the PHP code for what you are trying to do exactly?

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/11/10 05:37 
Before we talk about code, this is my purpose.
I'd like to sell a .mp3, or .wav at 3 differents prices, like you would choose a color for a sweat!
I'd like to sell royalty free music.
1) Would you know some guy, maybe you, who could explain me how to achieve this modification. (I'm php speaking) : files tables and functions to modify.
2) If not, do you know some cool dude who would know how to add 'options' to songs?(of course I'm talking about developing, because I imagine there is no 'options' in the current JR...)
3) How much could this cost ?
Thx for coming to my rescue...

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/11/10 13:16 
Unfortunately describing everything that would be involved in a system like that is way outside the scope of the forums. It would require a custom module with some mode hooks probably that would auto create multiple vault items for a given item at different prices. The cleanup and whatnot would be fairly involved as well.

Sorry!

kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/11/10 15:35 
You mean that nobody can do this on Earth ? Wasn't an American who walked on the Moon ? Maybe I'm confusing...

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/11/10 18:27 
No - I'm not saying it's impossible, just that describing everything that would be involved would be _way_ too much for the forums here. You would really need to spend some time looking through the module developer's guide and getting familiar with Jamroom at the php level:

http://www.jamroom.net/Module_Developer_Guide

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
artatum



Joined: 21 Oct 2010
Posts: 31

Posted: 11/12/10 00:55 
But isn't it possible for a member of the team to develop this module for some $$$ ?

Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.