I am working on a page where I need to resize the divs width based on how many pages are in the folder (for example if I have 2 pages, the divs should each be 50% width).
I have found the useful variable k_page_foldertotalpagecount which returns the correct number of pages in the current folder. The problem I am running into is when I try and divide 100 by that variable to get the % width for each div. For some reason that variable changes to 0 when PHP tries to use as an int. I have tried to manually convert it to an int and float but each time it gets changed to 0. When it is a string it has the right value.
How can I use this number without it changing to 0?
My code: (inside a pages tag with a folder selection)
I have found the useful variable k_page_foldertotalpagecount which returns the correct number of pages in the current folder. The problem I am running into is when I try and divide 100 by that variable to get the % width for each div. For some reason that variable changes to 0 when PHP tries to use as an int. I have tried to manually convert it to an int and float but each time it gets changed to 0. When it is a string it has the right value.
How can I use this number without it changing to 0?
My code: (inside a pages tag with a folder selection)
- Code: Select all
<?php
$count="<cms:show k_page_foldertotalpagecount/>";
echo gettype($count);//Currently a string
echo $count;//Returns the correct value but only when it is a string
$width = 100/$count; //Returns error because it is trying to divide by 0
echo "{$width}"; //Doesn't return anything
?>