Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-04-27 15:32:16

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_var : Easy variables and calculations

mrdale wrote:

I need it to do 0 decimal points as well (eg. 20.3689 becomes 20).

Thanks, bug fixed. Please upgrade plugin.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#14 2009-04-27 15:59:57

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: aks_var : Easy variables and calculations

Perfect… Thank you.

Offline

#15 2009-10-20 10:28:17

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: aks_var : Easy variables and calculations

i like. thank you.

Offline

#16 2009-12-30 16:41:25

pogonik
Member
Registered: 2008-03-20
Posts: 40
Website

Re: aks_var : Easy variables and calculations

Hi!

I had a little problem with understanding your plugin, so if someone can explane me something…

I wanted to calculate vertical space of “wrapp_box” class minus height of my thumbnail, so I can position it vertically in the middle. Here’s the page I’ve been talk about , so you can understand me better… I’ve been using “smart image resize” so calculation may look a little wierd…

First I’ve try with this code:

<txp:aks_var name="aspect_ratio" value="<txp:upm_img_full_width />" calc="/<txp:upm_img_full_height />" />
<txp:aks_var name="margo" value="185" calc="/<txp:aks_evar name="aspect_ratio" />" />
<txp:aks_var name="margo" calc="-200"/>
<span style="text-align:center; display:block; margin-top:<txp:aks_evar name="margo" calc="/2" substr="1"/>px;">
<a href="<txp:upm_img_alt />">
<img src="<txp:site_url />image.php?width=185&amp;height=150&amp;quality=85&amp;image=<txp:upm_img_full_url />" alt="" />
</a>
</span>

but that didn’t work…then, after a lot of trying, I’ve manage it to work with this code:

<txp:aks_var name="aspect_ratio" value="<txp:upm_img_full_width />" calc="/<txp:upm_img_full_height />" />
<txp:aks_var name="margo" value="185" calc="/<txp:aks_evar name="aspect_ratio" />" />
<txp:aks_var name="margo" value="<txp:aks_evar name="margo" />" calc="-200"/>
<span style="text-align:center; display:block; margin-top:<txp:aks_evar name="margo" value="<txp:aks_evar name="margo" />" calc="/2" substr="1"/>px;">
<a href="<txp:upm_img_alt />">
<img src="<txp:site_url />image.php?width=185&amp;height=150&amp;quality=85&amp;image=<txp:upm_img_full_url />" alt="" />
</a>
</span>
  1. first line – get aspect ratio
  2. second line – max image width (185) divided with aspect ratio (you get image height)
  3. third line – image height minus “wrapp_box” max height (200)
  4. forth line – result from third line (space left) divided by 2, subst first value (cos first value is minus)
    as I said, it may look wierd, because of smart image resizer…

You’ll probably notice in third and forth line that I was have to put value=”<txp:aks_evar name=“margo” />” even if the name of my var is “margo”. It didn’t work without it…
Why is that? As I get it from your explenation, my first code should work…or I didn’t get it right?

hope you’ve understand me.

Last edited by pogonik (2009-12-30 17:45:29)

Offline

#17 2012-02-12 16:22:20

karlfernandes
New Member
Registered: 2012-02-12
Posts: 5

Re: aks_var : Easy variables and calculations

This is a great plugin, but it’s giving me a “Function split() is deprecated” message. I’m running TXP on a server with PHP 5.3…

Can you please update the plaugin?

Offline

#18 2012-02-14 07:01:14

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_var : Easy variables and calculations

Thanks for feedback

update aks_var v0.3

Changes:

  • PHP 5.3 fix
  • Added attribute split

Last edited by makss (2016-01-16 18:14:14)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#19 2012-06-21 19:47:12

jens31
Plugin Author
From: munich / dtschermani
Registered: 2008-08-25
Posts: 183
Website

Re: aks_var : Easy variables and calculations

hi

thanks for this awesome plugin. using it quite often and its really easy to use..

but i encountered a problem. im trying to split a string and get the first value. but its not splitting. if i call for the second element of the splitted string, everything is fine, but i need the first element, which returns the full string :(
example (my_custom_field = mystring.ext):

<txp:aks_evar customfield="my_custom_field" split="1" delim="." />

returns:
mystring.ext
(but it should return mysting)

<txp:aks_evar customfield="my_custom_field" split="2" delim="." />

returns:
ext
(thats fine..)
tried the example of your site, which works fine, till you change split to 1, then its the same error..

edit

tried my luck and for now im happy.
the split line goes:
bc. if($split) { list($s1,$s2)=explode(‘:’, $split,2); if($s2){$s2=1;}else{$s2=0;}$tt=explode($delim, $value, $s1+$s2); $value=$tt[$s1-1]; }

changed the if($2) {$2=1;} else {$2=0;}
to $2=1;
and it works for me..

(dunno whats happening there, but i won ;)

Last edited by jens31 (2012-06-21 19:56:54)

Offline

Board footer

Powered by FluxBB