[solved] ctlModuleMaker previous/next syntax and columns
[solved] ctlModuleMaker previous/next syntax and columns
I'm trying to get the previous/next function on the detail pages. I'm not sure what i'm checking for being loaded, and how. Can anyone show me the syntax?
not this.. {if $previous_item != ""}{$previous_item}{/if}
This is the hint of the available smarty variable $previous_item (if loaded)
...kicking and screaming into learning smarty
After this i have one more hurdle - list results into columns
Thanks!
not this.. {if $previous_item != ""}{$previous_item}{/if}
This is the hint of the available smarty variable $previous_item (if loaded)
...kicking and screaming into learning smarty
After this i have one more hurdle - list results into columns
Thanks!
Last edited by edented on Wed Sep 09, 2009 8:53 pm, edited 1 time in total.
Re: ctlModuleMaker previous/next syntax
the $previous_item variable does not contain a value, but an object, just like the $item variable. As the attributes are the same as $item, I did not enumerate them all a second time in the template help. But I assume what you are looking is something like :
Now, what kind of columns do you wish exactly?
Pierre-Luc
Code: Select all
{if $previous_item}{$previous_item->detaillink}{/if}
Pierre-Luc
Re: ctlModuleMaker previous/next syntax
Thanks! That works. I take it i can make it say previous/next instead of the name.
As for the columns, I would like to be able to display the results (child elements of a category) in a more compact manor, rather than a single column. Ideally i would like to be able to determine in the template that it has 3 columns (or 4 or 5 or 2). Normally I've had this in a php loop, but i'm unsure of how this fits into the smarty world.
It would be great to see a fairly complex template to study.
Thanks again!
As for the columns, I would like to be able to display the results (child elements of a category) in a more compact manor, rather than a single column. Ideally i would like to be able to determine in the template that it has 3 columns (or 4 or 5 or 2). Normally I've had this in a php loop, but i'm unsure of how this fits into the smarty world.
It would be great to see a fairly complex template to study.
Thanks again!
Re: ctlModuleMaker previous/next syntax
Here you go :edented wrote:I take it i can make it say previous/next instead of the name.
Code: Select all
{if $previous_item}
<a href="{$previous_item->detailurl}">Previous</a>
{/if}
Code: Select all
{assign var="nbcol" value=2}
{assign var="nbpercol" value="false"}
{foreach from=$itemlist item="item" key="key" name="itemlistloop"}
{if !$nbpercol}
{math equation="ceil(itemcount / nbcol)" itemcount=$smarty.foreach.itemlistloop.total nbcol=$nbcol assign="nbpercol"}
{if $nbpercol == 0}{assign var="nbpercol" value="1"}{/if}
{/if}
{if $key == 0 || ($key+1) is not div by $nbcol}
{if $key != 0}</ul></div>{/if}<div style="float: left;"><ul>
{/if}
<li>{$item->name}</li>
{if $smarty.foreach.itemlistloop.last}</ul></div>{/if}
{/foreach}
Re: ctlModuleMaker previous/next syntax
Hey that definitely points me in the right direction. I will work with it later trying both areas and let you know how it goes. Thanks again for your help.
Re: ctlModuleMaker previous/next syntax
No luck with the columns yet. I'm not much of a programmer
Trying the smarty template approach with floated div tags has some interesting results.
http://www.onrampstudios.com/cmsms/index.php?page=2column
Trying to insert/adjust the working column php code that i have into the action.defalut.php gave plenty wrong results with the table repeating. I'm not sure what to wrap it around. Here's the php. Ideally though, it would be great to not have to go edit the php to change the number of columns (assuming it can be made to work).
$num_cols = 2; // the number of columns
$total_records = count($itemlist);
$num_rows = ceil($total_records / $num_cols); // the number of rows
$num = 0; // don't change this value, this is the first number of each record inside a record set
echo "\n";
// next the loop for the table rows
for ($rows = 0; $rows \n";
// this is the loop for the table columns
for ($cols = 0; $cols alias />
".$description."
\n";
} else { // show an empty cell
echo " \n";
}
$num++; // raise the number by one for the next record
}
echo "\n"; // there are no more cols in this row, close the table row tag
}
echo "\n"; // end of the region = closing tag for the table element
Any ideas? Should this be a feature request? Thanks for any ideas
Trying the smarty template approach with floated div tags has some interesting results.
http://www.onrampstudios.com/cmsms/index.php?page=2column
Trying to insert/adjust the working column php code that i have into the action.defalut.php gave plenty wrong results with the table repeating. I'm not sure what to wrap it around. Here's the php. Ideally though, it would be great to not have to go edit the php to change the number of columns (assuming it can be made to work).
$num_cols = 2; // the number of columns
$total_records = count($itemlist);
$num_rows = ceil($total_records / $num_cols); // the number of rows
$num = 0; // don't change this value, this is the first number of each record inside a record set
echo "\n";
// next the loop for the table rows
for ($rows = 0; $rows \n";
// this is the loop for the table columns
for ($cols = 0; $cols alias />
".$description."
\n";
} else { // show an empty cell
echo " \n";
}
$num++; // raise the number by one for the next record
}
echo "\n"; // there are no more cols in this row, close the table row tag
}
echo "\n"; // end of the region = closing tag for the table element
Any ideas? Should this be a feature request? Thanks for any ideas
Re: ctlModuleMaker previous/next syntax
The problem with your floating divs is quite simple : because your pictures are in a list ( ul -> li ), and because your lists have no style or a style with a padding, there's a padding on the left of your pictures. Hence there's not enough space to fit all your columns. Just remove the padding from the list, or replace the and with , and your columns should be nice (provided that the images aren't too large).
Re: ctlModuleMaker previous/next syntax
Here:
(notice I added a div with clear left at the bottom, just to make sure the container would extend with the floating content)
(notice 2: you could give a width to your div to make sure they are all the same width... right now they will be as large as the largest image they contain)
Note that if you don't care about the order being left to right instead of top to bottom, you could simply do :
(ideally with a fixed width)
and they'd just stack horizontally and go to the next line once the first is full...
Code: Select all
{assign var="nbcol" value=3}
{assign var="nbpercol" value="false"}
{foreach from=$itemlist item="item" key="key" name="itemlistloop"}
{if !$nbpercol}
{math equation="ceil(itemcount / nbcol)" itemcount=$smarty.foreach.itemlistloop.total nbcol=$nbcol assign="nbpercol"}
{if $nbpercol == 0}{assign var="nbpercol" value="1"}{/if}
{/if}
{if $key == 0 || ($key+1) is not div by $nbcol}
{if $key != 0}</div>{/if}<div style="float: left;">
{/if}
{$item->name}<br/>
{if $smarty.foreach.itemlistloop.last}</div>{/if}
{/foreach}
<div style="clear: left;"></div>
(notice 2: you could give a width to your div to make sure they are all the same width... right now they will be as large as the largest image they contain)
Note that if you don't care about the order being left to right instead of top to bottom, you could simply do :
Code: Select all
{foreach from=$itemlist item="item"}
<div style="float: left; padding: 10px;">{$item->name}</div>
{/foreach}
<div style="clear: left;"></div>
and they'd just stack horizontally and go to the next line once the first is full...
Re: ctlModuleMaker previous/next syntax
The simpler method works best for the moment. Setting the div height as well as the width turned out to be important for the flow, unless the image heights were all the same. Now i can simply duplicate the template and adjust the widths to for however many columns i need for the category.
For future reference...
#############
{* set the div width to determine # of columns fitting in 800px #main-container. don't forget there might be padding*}
{foreach from=$itemlist item="item"}
{* display name, then image, or whatever content *}
{if $item->is_selected}class="active"{/if}{$item->detaillink}
{if $item->image != ""}detailurl}">
image->thumbnail}" alt=""/>
{/if}
{/foreach}
#############
Thanks Pierre-Luc for your immediate response and dedication. It is very much appreciated.
For future reference...
#############
{* set the div width to determine # of columns fitting in 800px #main-container. don't forget there might be padding*}
{foreach from=$itemlist item="item"}
{* display name, then image, or whatever content *}
{if $item->is_selected}class="active"{/if}{$item->detaillink}
{if $item->image != ""}detailurl}">
image->thumbnail}" alt=""/>
{/if}
{/foreach}
#############
Thanks Pierre-Luc for your immediate response and dedication. It is very much appreciated.
Re: ctlModuleMaker previous/next syntax and columns
Updating to version 1.8.9.1 seems to have broken previous/next continuity in detail pages.
http://www.onrampstudios.com/cmsms/index.php?page=landscapes
I have a query that calls for the children of a category. The results are now displayed on the front end (yea! soon i'll play with complex ordering). And i can even get the nbperpage to work within that query (see below)
{cms_module module='ai_web' action='default' nbperpage='6' forcelist='0' searchmode='advanced' query='3' }
I seem to have a problem with regular page module calls and the nbperpage within a subset of records.
No results with this:
{cms_module module='ai_web' action='default' what='artworks(final level)' parent='Landscapes(subcategory)' forcelist='0' searchmode='advanced' limit='0' nbperpage='6' }
While this seems to ignore the 'Landscapes', calling all final level items while enforcing the nbperpage.
{cms_module module='ai_web' action='default' what='Landscapes' forcelist='0' searchmode='simple' limit='0' nbperpage='6' }
temporary example link
http://www.onrampstudios.com/cmsms/index.php?page=modulecalls
So it goes today.
http://www.onrampstudios.com/cmsms/index.php?page=landscapes
I have a query that calls for the children of a category. The results are now displayed on the front end (yea! soon i'll play with complex ordering). And i can even get the nbperpage to work within that query (see below)
{cms_module module='ai_web' action='default' nbperpage='6' forcelist='0' searchmode='advanced' query='3' }
I seem to have a problem with regular page module calls and the nbperpage within a subset of records.
No results with this:
{cms_module module='ai_web' action='default' what='artworks(final level)' parent='Landscapes(subcategory)' forcelist='0' searchmode='advanced' limit='0' nbperpage='6' }
While this seems to ignore the 'Landscapes', calling all final level items while enforcing the nbperpage.
{cms_module module='ai_web' action='default' what='Landscapes' forcelist='0' searchmode='simple' limit='0' nbperpage='6' }
temporary example link
http://www.onrampstudios.com/cmsms/index.php?page=modulecalls
So it goes today.
Re: [solved] ctlModuleMaker previous/next syntax and columns
For simplicity,
could very well be
(searchmode has no effect outside the search action, and your other parameters all have the default value)
The nbperpage / parent problem was a bug. I fixed it and uploaded 1.8.9.2 files.
Code: Select all
{cms_module module='ai_web' action='default' what='artworks' parent='Landscapes' forcelist='0' searchmode='advanced' limit='0' nbperpage='6'}
Code: Select all
{cms_module module='ai_web' parent='Landscapes' nbperpage='6'}
The nbperpage / parent problem was a bug. I fixed it and uploaded 1.8.9.2 files.
Re: [solved] ctlModuleMaker previous/next syntax and columns
Working beautifully. Thanks for fixing that.
When i use the parent and nbperpage, the resulting page numbers reflect the entire number of children rather than just the subset.
An easy workaround:
create a query that calls a specific subset. Call the query id and use nbperpage, gives the right amount of pages (don't use the sort option as details come out of the item order).
When i use the parent and nbperpage, the resulting page numbers reflect the entire number of children rather than just the subset.
An easy workaround:
create a query that calls a specific subset. Call the query id and use nbperpage, gives the right amount of pages (don't use the sort option as details come out of the item order).
Re: [solved] ctlModuleMaker previous/next syntax and columns
Damn, I had fixed that but I forgot to add the parameter to the function... you can fix this by editing the module file (modulename.module.php), finding the line :
And changing it to :
Code: Select all
function countsomething($tablename,$what="id",$where=array(),$wherestring=false,$wherevalues=array()){
Code: Select all
function countsomething($tablename,$what="id",$where=array(),$wherestring=false,$wherevalues=array(),$parent=false){