Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 24. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Assign a filter to its own button?

phpMyEdit Configuration     Assign a filter to its own button?
Odoslať novú tému   Odpovedať na tému    
 
jtzako     Založený: 12.01.2017   Príspevky: 16  
Príspevok Zaslal: 2017-01-12 19:03
Návrat hore  Odpovedať s citátom     

I'd like to create buttons or tabs of some sort in List view that will let me filter based on one of my fields.

I have a column that has the date in it. I want a separate button for each month of the year.

I am able to make a filter using the built in filters, but I dont know if it is possible to assign a filter to a button.

i.e.

$opts['filters'] = "Date like '12/%'";

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2017-01-12 23:26
Návrat hore  Odpovedať s citátom     

near the top of the page, change date_column to your column's name


$fl2 = array_key_exists('fl2', @$_REQUEST) ? strip_tags(stripslashes(trim(@$_REQUEST['fl2']))) : '';

if($fl2 > '') {

$opts['cgi']['persist'] = array('fl2' => $fl2);

$opts['filters'] = 'date_column REGEXP "^'.$fl2.'"';

echo "\n".'<p>'.htmlentities($opts['filters'], ENT_QUOTES, 'UTF-8').'</p>';


}


near the page footer try this

$this_year = date('Y');
$string1 = '';
$separator = ' &ndash; ';
foreach(range(1, 12, 1) as $mo){
$string1 .= '<a href="'.basename($_SERVER['PHP_SELF']).'?fl2='.$this_year.'-'.sprintf("%02d", $mo).'" hreflang="en-us">'.$this_year.'-'.sprintf("%02d", $mo).'</a>';
$mo < 12 ? $string1 .= $separator : '';
}
echo "\n".'<p>'.$string1.'</p>';

 
jtzako     Založený: 12.01.2017   Príspevky: 16  
Príspevok Zaslal: 2017-01-13 00:47
Návrat hore  Odpovedať s citátom     

Thanks a bunch, this worked great.

I made some changes so it wont print the REGEX line up top, and detects which month it is and makes a button with the months actual name instead of a numbered link. I also added an ALL button for an easy way back to the full list.

/ Get the month for filtering
$month = array_key_exists('month', @$_REQUEST) ? strip_tags(stripslashes(trim(@$_REQUEST['month']))) : '';

if($month > '') {

$opts['cgi']['persist'] = array('month' => $month);

$opts['filters'] = 'CMDate REGEXP "^'.$month.'"';

// echo "\n".'<p><font color=black>'.htmlentities($opts['filters'], ENT_QUOTES, 'UTF-8').'</font></p>';

}

$this_year = date('Y');
$string1 = '';
$separator = ' ';
$cmmonth = '';
foreach(range(1, 12, 1) as $mo){
if ($mo == "01") { $cmmonth = "January"; } elseif ($mo == "02") { $cmmonth = "February"; } elseif ($mo == "03") { $cmmonth = "March"; }
elseif ($mo == "04") { $cmmonth = "April"; } elseif ($mo == "05") { $cmmonth = "May"; } elseif ($mo == "06") { $cmmonth = "June"; }
elseif ($mo == "07") { $cmmonth = "July"; } elseif ($mo == "08") { $cmmonth = "August"; } elseif ($mo == "09") { $cmmonth = "September"; }
elseif ($mo == "10") { $cmmonth = "October"; } elseif ($mo == "11") { $cmmonth = "November"; } elseif ($mo == "12") { $cmmonth = "December"; }
$string1 .= '<a href="'.basename($_SERVER['PHP_SELF']).'?month='.sprintf("%02d", $mo).'" hreflang="en-us" class="button">'.sprintf("$cmmonth").'</a>';
$mo < 12 ? $string1 .= $separator : '';
}
echo "\n".'<p>'.$string1.' <a href="'.basename($_SERVER['PHP_SELF']).'?month="" hreflang="en-us" class="button">All</a></p>';

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov