Admin Dropdown

Started by Matthew K., January 03, 2010, 10:40:03 AM

Previous topic - Next topic

Matthew K.

Hello everyone!

I made a Forum Cursor Mod, and as suggested by the SMF Customization Team, I am going to be switching to a dropdown instead of text, for multiple reasons.

However, I am unsure on how exactly to call up the input, so guidance would be appreciated.

Code (My CSS) Select
$context['html_headers'] .='<style type="text/css">
body
{
cursor: ' . (!empty($modSettings['forum_cursor']) ? ''. $modSettings['forum_cursor']. '' : 'auto') . ';
}
</style>';

Code (My Array) Select
array('select', 'forum_cursor', array(1 => &$txt['cursor_default'], 2 => &$txt['cursor_crosshair'], 3 => &$txt['cursor_hand'], 4 => &$txt['cursor_pointer'], 5 => &$txt['cursor_move'], 6 => &$txt['cursor_text'], 7 => &$txt['cursor_wait'])),

In the end, I need the value of forum_cursor to be a txt string (one of the cursors) which are defined in Modifications.english.php.

Labradoodle-360

Arantor


$css = array(1 => $txt['cursor_default'], 2 => $txt['cursor_crosshair'], 3 => $txt['cursor_hand'], 4 => $txt['cursor_pointer'], 5 => $txt['cursor_move'], 6 => $txt['cursor_text'], 7 => $txt['cursor_wait']);
$context['html_headers'] .='<style type="text/css">
body
{
cursor: ' . (!empty($modSettings['forum_cursor']) ? ''. $css[$modSettings['forum_cursor']] . '' : 'auto') . ';
}
</style>';


The value you get is a number relating to the array you have, so in your array $txt['cursor_default'] will store 1 in $modSettings['forum_cursor']. Thus you have to look back up what 1 refers to, just like I did in Version Emulate Dropdown.

Matthew K.

#2
After the last PM I received, I figured it was something like that, I just wasn't positive on how to write it and include it.

Thanks Arantor, marking as resolved.
Labradoodle-360

Matthew K.

This isn't working, suggestions?

Arantor

* Arantor really wishes people would read the quote in his signature. Might mean I don't have to make 50% of my posts each day asking the same time-wasting question.

So, anything in the error log?

Matthew K.

Okay Arantor, maybe my post wasn't clear enough, I thought I had stated what I needed done.

No error logs related to the forum_cursor array. What's not working, is that when inputted via Admin panel, nothing is entered to the CSS (or properly entered) meaning the cursor doesn't change.

Arantor

Nothing added at all to the source? That suggests you're putting this in the wrong place.

Where, exactly, is this code?

Matthew K.

It's placed right below Poll Options on Features and Options General, as my mods xml shows.

Arantor

That wasn't what I meant.

Where, exactly, is the OTHER bit of code, the one that process of elimination and logic tells us isn't working?

Matthew K.

The other code, the CSS, is placed in Load.php where I was previously advised to place it.

The placing can't be the problem, because with a text field it works perfectly.
Labradoodle-360

Arantor

In which case, do as I suggested earlier, and verify what exactly is added to the source of the page.

Matthew K.


Matthew K.

Using FireBug, index.php?action=admin;area=featuresettings;sa=basic shows as

body {
}

Arantor

That tells me the code isn't adding to $context['html_headers']. Which means you've put that in the wrong place or there is something else wrong.

Matthew K.

I assume it's something else is wrong, because when it's a text field it works, any further ideas on how to diagnose the problem?

Arantor

I can't see how it can, since the cursor part is missing which suggests the whole thing is broken.

Matthew K.

#16
True, I'll compare it to my context...in the case of a typo. - Compared, and exactly the same except for the top line that defines $css and then adding $css[$modSettings['forum_cursor']].

I honestly don't get what could be wrong, the simple change from text to dropdown disables it...

Code (My code is below this) Select
// Detect the browser. This is separated out because it's also used in attachment downloads
detectBrowser();


I also checked to make sure cursor wasn't being defined in Load.php by another code.

Matthew K.

Maybe it'll help if I post my whole code, I'll post a section or two on either side of both edits so you can see where it's being added to each document.

Code (Load.php) Select

// A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
$context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];

// Detect the browser. This is separated out because it's also used in attachment downloads
detectBrowser();


   $cursortext = array(1 => $txt['cursor_default'], 2 => $txt['cursor_crosshair'], 3 => $txt['cursor_hand'], 4 => $txt['cursor_pointer'], 5 => $txt['cursor_move'], 6 => $txt['cursor_text'], 7 => $txt['cursor_wait']);
   $context['html_headers'] .='<style type="text/css">
   body
   {
   cursor: ' . (!empty($modSettings['forum_cursor']) ? ''. $cursortext[$modSettings['forum_cursor']] . '' : 'auto') . ';
   }
   </style>';

Code (ManageSettings.php) Select
function ModifyBasicSettings($return_config = false)
{
global $txt, $scripturl, $context, $settings, $sc, $modSettings;

$config_vars = array(
// Big Options... polls, sticky, bbc....
array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),
'',

array('select', 'forum_cursor', array(1 => &$txt['cursor_default'], 2 => &$txt['cursor_crosshair'], 3 => &$txt['cursor_hand'], 4 => &$txt['cursor_pointer'], 5 => &$txt['cursor_move'], 6 => &$txt['cursor_text'], 7 => &$txt['cursor_wait'])),
    '',

Arantor

And once it's set up, please post the full HTML of the page in question. You cannot get body { } out of that. It's one line of code, and it would contain the cursor declaration.

Matthew K.

You're right, going into the HTML Source, here is what the output of the code in Load.php is<style type="text/css">
   body
   {
   cursor: ;
   }
   </style>

Advertisement: