MarsHut Page 1/4

obsequiousravioliΛογισμικό & κατασκευή λογ/κού

29 Οκτ 2013 (πριν από 3 χρόνια και 10 μήνες)

94 εμφανίσεις

Hard coded increments in getLimitBox()
Asked by
Nick Weavers
on 2013-05-01T14:50:47-04:00
I have a component in which I am creating a list (via JModelList) which
consists of 4 items per row in a view layout.

I would like to change the values that appear in the selection list
generated by JPagination's getLimitBox() but I see they are hard coded to
start at 5 and got to 30 in increments of 5, followed by 50 and then All.

What would be the best way to go about getting this list to use increments
based on multiples of 4? Should I overload the method, and if so how would
I get my extended JPagination to be used?

TIA,
Nick Weavers
Archives
Framework
Joomla
May 1, 2013
Week 18, 2013
May, 2013
Year 2013
All Answers
Answer by
Viper
on 2013-05-01T16:27:56-04:00
Interesting too.
And I want to know how to setup custom limit for different pages that
display limitbox(e.g. for view "articles1" it's set to 20 per page,
"articles2" - 10 and so...). 'cause it is setup global. Yes, I can override
limit in the model(via $this->setState('list.limit', 10)), but maybe it can
be set via JPagination?
Answer by
Nick Weavers
on 2013-05-01T16:30:16-04:00
There may be much better ways to do it, but a quick solution for me was to
use the pagination layout override in the template since I only have one
list being built by this component...

function pagination_list_footer($list)

$html = "
\n";

$limits = array();

// Make the option list.
for ($i = 4; $i

$limits[] = JHtml::_('select.option', "$i");

$selected = $list->limit;
MarsHut
Page 1/4
Hard coded increments in getLimitBox()

$limitfield = JHtml::_(
'select.genericlist',
$limits,
'limit',
'class="inputbox" size="1" onchange="this.form.submit()"',
'value',
'text',
$selected
);

$html .= "\n
Show ".$limitfield." vehicles per
page
";
$html .= $list['pageslinks'];
$html .= "\n
".$list['pagescounter']."
";

$html .= "\n
value=\"".$list['limitstart']."\" />";
$html .= "\n
";

return $html;
Answer by
Viper
on 2013-05-02T04:30:53-04:00
I made some fixes for the getLimitBox() method. Check my post at CMS dev
group https://groups.google.com/forum/#!topic/joomla-dev-cms/uKe3jjyPNqs
and post the suggestion. Maybe I have something left out.
Answer by
Denis Ryabov
on 2013-05-02T04:40:49-04:00
There may be much better ways to do it, but a quick solution for me was to use the pagination layout
override in the template since I only have one list being built by this component... function
pagination_list_footer($list){    $html = "
\n";        $limits = array();     // Make the option
list.    for ($i = 4; $i
limit;        $limitfield = JHtml::_(        'select.genericlist',       
$limits,        'limit',        'class="inputbox" size="1" onchange="this.form.submit()"',     
  'value',        'text',        $selected    );         $html .= "\n
Show ".$limitfield."
vehicles per page
";$html .= $list['pageslinks'];$html .= "\n
".$list['pagescounter']."
"; $html .= "\n
";$html .= "\n
"; return $html;} --   
Answer by
Viper
on 2013-05-02T05:40:49-04:00
Re: [jgen] Re: Hard coded increments in getLimitBox()

Здравствуйт&#107
7;, Denis.

Приветствую!

Изменил так

public function getLimitBox($list_values=array(), $all=true) {
...
// Make the option list.
MarsHut
Page 2/4
Hard coded increments in getLimitBox()
for ($i=0, $n=count($list_values); $i
$limits[] = JHtml::_('select.option', $list_values[$i]);

if ($all) {
$limits[] = JHtml::_('select.option', '0', JText::_('JALL'));

...

Вы писали 2 мая
2013 г., 11:40:49:

Viper, I think it's better to pass an iterable object (array of elements, generator, etc.) instead of 4
parameters $start, $total, $step, and $extra.

PS. Does anybody know reason of J50 and J100 lang constants in Joomla?

Best regards,
Denis Ryabov

02.05.2013, 12:30, "Viper"
:
I made some fixes for the getLimitBox() method. Check my post at CMS dev group
https://groups.google.com/forum/#!topic/joomla-dev-cms/uKe3jjyPNqs and post the suggestion.
Maybe I have something left out.


There may be much better ways to do it, but a quick solution for me was to use the pagination
layout override in the template since I only have one list being built by this component...

function pagination_list_footer($list)

$html = "
\n";

$limits = array();

// Make the option list.
for ($i = 4; $i

$limits[] = JHtml::_('select.option', "$i");

$selected = $list->limit;

$limitfield = JHtml::_(
'select.genericlist',
$limits,
'limit',
'class="inputbox" size="1" onchange="this.form.submit()"',
'value',
'text',
$selected
);

$html .= "\n
Show ".$limitfield." vehicles per page
";
MarsHut
Page 3/4
Hard coded increments in getLimitBox()
$html .= $list['pageslinks'];
$html .= "\n
".$list['pagescounter']."
";

$html .= "\n
";
$html .= "\n
";

return $html;
Answer by
Nick Weavers
on 2013-05-02T06:14:51-04:00
Yes, I like the idea of passing a list as Dennis suggested as it allows
discrete values to be passed easily giving more flexibility.
Answer by
Ove
on 2013-05-03T05:16:06-04:00
Nice!
Just remember B/C. It has to default to the values as is.

Viper wrote On 02.05.2013 11:40:
Tagged
Extended Jpagination
Getlimitbox
Hard Coded
Hard Coded Increments
Selection List
Related
X-Content-Encoded-By
View Online
http://www.marshut.com/ktnmq/hard-coded-increments-in-getlimitbox.html
MarsHut
Page 4/4