View Full Version : Columns for Check Boxes and Multiple Categories
dhowler
01-26-2007, 09:11 AM
1) Columns for Check Boxes
I have a lot of check boxes for one of my custom fields. I was wondering if instead of
Action | Adventure | Alternate Universe (AU)
I get something like:
Action ------------------------------ Adventure -------------------------- Alternate Universe (AU)
(ignore lines, it's just formatting)
In other words, a simple 2 or three column table.
----------------------------------------------------------------------------------------------------------------------------
2) Submit Links to Multiple Categories
I know that there is an admin feature that allows you to copy links to another category, but it would be much more helpful if the person submitting the link could do this automatically. Is this possible?
Dreamy
John Turner
01-29-2007, 04:39 AM
Hi Dreamy,
Here the solution for you.
1. open '../util.php'
*** before '?>' in the bottom of document add following code
function print_table_checkbox($aParam)
{
global $gDirLang;
$num_col = 4;
$out = '<table cellpadding = "2" cellspacing ="2" ><tr>';
$i=1;
foreach ($aParam['fields'] as $key => $value)
{
$checked = in_array($value,$aParam['defaults']) ? '"checked"' : '';
$out .= '<td><input type="checkbox" name="'.$aParam['field_name'].'[]" value="'.$value.'" id="ch'.$value.'" '.$checked.' /><label for="ch'.$value.'">'.$gDirLang['field_'.$aParam['field_name'].'_'.$key].'</label></td>';
if (0 == $i % $num_col)
{
$out .= "</tr>\n<tr>";
}
$i++;
}
$out .= "</tr></table>";
echo $out;
}
4 number of columns of output table.
*** Save and close it.
2. open '../classes/DirSmarty.php'
**find following code
$gDirSmarty->register_function("array_to_lang", "array_to_lang");
$gDirSmarty->register_function("print_stars", "print_stars");
** replace with following code
$gDirSmarty->register_function("array_to_lang", "array_to_lang");
$gDirSmarty->register_function("print_stars", "print_stars");
$gDirSmarty->register_function("print_table_checkbox", "print_table_checkbox");
*** Save and close it.
3. open '../templates/{YOUR TEMPLATE}/suggest-link.tpl'
**find following code
{foreach from=$field.values item=checkbox name=checkbox_field}
{in_array_exist values=$def_check def=$checkbox}
{if $result_valid}
{assign var="checked" value='checked="checked"'}
{else}
{assign var="checked" value=''}
{/if}
{assign var="field_title_val" value='field_'|cat:$field.name|cat:'_'|cat:$smarty .foreach.checkbox_field.iteration-1}
<input type="checkbox" name="{$key}[]" value="{$checkbox}" id="ch{$checkbox}" {$checked} /><label for="ch{$checkbox}">{$lang.$field_title_val}</label>
{/foreach}
** replace with following code
{print_table_checkbox fields=$field.values field_name=$field.name defaults=$def_check}
*** Save and close it.
It might helps.
dhowler
01-29-2007, 10:01 AM
John,
Well, I thought that editing the admin/util.php would work too, but it didn't. Though, works great for the user! Only problem is that I put in 99% of the links myself. So I just need to get it to work for the admin add/edit too.
Here's my new User Submit a Link: http://recs.citadelofthewolf.com/suggest-link.php?id=0
It does look 100% better let me tell you.
Well, that's one part down!
John Turner
01-29-2007, 10:29 AM
Hi again,
Here code hack for back-end.
open '../admin/suggest-link.php'
*** find following code
if ($checkboxes)
{
$cnt = count($checkboxes);
$i = 0;
foreach($checkboxes as $ind=>$item)
{
$i++;
$checked = (in_array($item, $default)) ? ' checked="checked"' : '';
echo "<input type=\"checkbox\" name=\"{$value['name']}[]\" id=\"{$value['name']}_{$item}\" value=\"{$item}\" {$checked} />";
echo "<label for=\"{$value['name']}_{$item}\">{$gDirLang['field_'.$value['name'].'_'.$ind]}</label>";
echo ($i != $cnt) ? ' | ' : '';
}
}
*** replace with following code
if ($checkboxes)
{
$cnt = count($checkboxes);
$i = 0;
$num_col = 4;
echo '<table cellpadding = "2" cellspacing ="2" ><tr>';
foreach($checkboxes as $ind=>$item)
{
$i++;
$checked = (in_array($item, $default)) ? ' checked="checked"' : '';
echo "<td><input type=\"checkbox\" name=\"{$value['name']}[]\" id=\"{$value['name']}_{$item}\" value=\"{$item}\" {$checked} />";
echo "<label for=\"{$value['name']}_{$item}\">{$gDirLang['field_'.$value['name'].'_'.$ind]}</label></td>";
if (0 == $i % $num_col)
{
echo "</tr>\n<tr>";
}
}
echo "</tr></table>";
}
*** save and close it.
That's all.
dhowler
01-29-2007, 10:41 AM
Thank You! You are a total angel!
Now if I can just get help on how to submit to multiple categories. Too bad this doesn't seem to be a 2.1 fix. :(
Dreamy
John Turner
01-30-2007, 05:32 AM
You are welcome Dreamy,
Thanks for such kind words.
Now if I can just get help on how to submit to multiple categories. Too bad this doesn't seem to be a 2.1 fix.
I can implement this modification for $50 (3-4 business days)
I suppose this modification will be included to our V2.2 PRO. :)
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.