News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Need help with coding...

Started by onijin, May 31, 2006, 07:57:44 PM

Previous topic - Next topic

onijin

I cant seem to get it the way I want.

What I'm trying to do, is create a selection box in settings with all the boards (and support multiple selections)

this is what I have, but doesn't seem to be working...

                                        <input type="hidden" name="ar_board" value="', empty($modSettings['ar_board']) ? '0' : $modSettings['ar_board'], '" />
                                        <select name="ar_board" id="ar_board_select" multiple size="8">
                                                <option></option>';
        foreach ($context['boards'] as $board)
                echo '
                                        <option value="', $board['id'], '"', isset($modSettings['ar_board']) && $board['id']==$modSettings['ar_board'] ? ' selected="selected"' : '', '>', $board['category']['name'], ' - ', $board['name'], '</option>';
        echo '
                                        </select>';


and impliment it into this:

    if ($board == ', $context['ar_board'], ')


where    ', $context['ar_board'], ' is the board(s) selected.

any advice?

onijin

Hmm... Been messing with it for a while now and still can't get it.

Everytime I choose more than one board, it crashes.

Rudolf

It makes no sense what you ask.
What are you trying to do? What are the results you expect?
Anyway try changing your select statement in this:
<select name="ar_board[]" id="ar_board_select" multiple size="8">
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

onijin

Sorry if I wasn't clear.

I was modding my manageboards.template.php to add more settings.  The multi-select box is supposed to be able to let you select multiple boards to apply the settings to.  Which ever boards are selected, I wan't it to be plugged into

if ($board == ', $context['ar_board'], ')

where ', $context['ar_board'], ' are the boards selected.

Im guessing an array would work, but not too sure how to code the array.

Does that make any sense?

JayBachatero

This

if ($board == ', $context['ar_board'], ')


Should be

if ($board == $context['ar_board'])
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

Yeah?  Simple as that?

It would work even if there's multiple selections?

JayBachatero

What exactly are you trying to do?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin



select multiple boards and let it affect that bit of code.

So IF which ever boards are chosen are entered, it'll execute another bit of code.

JayBachatero

Ummm not sure how you would acomplish that.  Basically you want to show only the selected boards topics?  Like this http://www.simplemachines.org/community/index.php?action=unread;boards=9,10
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

#9
Okay...

Forget all that.

I went a different route.

Now my issue is, I made a column in my smf_boards table (called 'ar_restrictage'), but when I try to reference or modify the value with
<input type="text" name="ar_restrictage" value="', $context['board']['ar_restrictage'], '" />
(which I put in create new/edit boards section of Manageboards.template.php)

I wanted to be able to have a choosable & different value for each board.

JayBachatero

What is the code that you are using?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

onijin

Well, this is what I'm  TRYING  to use, taken from Manageboards.template.php


<tr>
<td>
<b>', $txt['ar_restrictage'], '</b><br />
', $txt['ar_restrictage_desc'], '<br /><br />
</td>
<td valign="top" align="right" style="white-space: nowrap;">
<input type="text" name="ar_restrictage" id="ar_restrictage" value="', $context['board']['ar_restrictage'], '" size="2" />
</td>
</tr>


The column (ar_restrictage) is located in the smf_boards table.  The value on default is 0, but the box in Manageboards.template.php is empty.  If I try to add the number and save, it just returns blank again.

winrules

Quote from: onijin on June 09, 2006, 07:26:09 PM
Well, this is what I'm  TRYING  to use, taken from Manageboards.template.php


<tr>
<td>
<b>', $txt['ar_restrictage'], '</b><br />
', $txt['ar_restrictage_desc'], '<br /><br />
</td>
<td valign="top" align="right" style="white-space: nowrap;">
<input type="text" name="ar_restrictage" id="ar_restrictage" value="', $context['board']['ar_restrictage'], '" size="2" />
</td>
</tr>


The column (ar_restrictage) is located in the smf_boards table.  The value on default is 0, but the box in Manageboards.template.php is empty.  If I try to add the number and save, it just returns blank again.
Hvae you modified anything else? Because you will also need to modify some querys to save and retrive the information from the database.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


onijin

I figured that...

but don't know where exactly to add it... (and what to add exactly)

hehe...  ^_^

onijin

#14
Okay.

I was able to get it saving.

just added in manageboards.php

      $boardOptions['ar_restrictage'] = (int) $_POST['ar_restrictage'];

and it worked.

thanks for the hep guys.

onijin

I have another question if y'all don't mind...

I pulled this from sources/Profile.php


// Set the age...
if (empty($context['member']['birth_date']))
{
$context['member'] +=  array(
'age' => &$txt[470],
'today_is_birthday' => false
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$context['member'] += array(
'age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}


The number it generates, I want to post this into a column in the _members table (which I already created).

How would I go about doing this?

Advertisement: