octocatstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">

	<file name="$sourcedir/Load.php">
		<operation>
			<search position="after"><![CDATA[		'gender' => array(]]></search>
			<add><![CDATA[		'favourite_item' => $profile['favourite_item'],
]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[			mem.birthdate, mem.member_ip, mem.member_ip2, mem.icq, mem.aim, mem.yim, mem.msn, mem.posts, mem.last_login,]]></search>
			<add><![CDATA[			mem.birthdate, mem.member_ip, mem.member_ip2, mem.icq, mem.aim, mem.yim, mem.msn, mem.posts, mem.last_login, mem.favourite_item,]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[			mem.openid_uri, mem.birthdate, mem.icq, mem.aim, mem.yim, mem.msn, mem.posts, mem.last_login, mem.karma_good,]]></search>
			<add><![CDATA[			mem.openid_uri, mem.birthdate, mem.icq, mem.aim, mem.yim, mem.msn, mem.posts, mem.last_login, mem.karma_good, mem.favourite_item,]]></add>
		</operation>
	</file>
	
	<file name="$sourcedir/ManageSettings.php">
		<operation>
			<search position="before"><![CDATA[		// Mod authors, add any settings UNDER this line. Include a comma at the end of the line and don't remove this statement!!]]></search>
			<add><![CDATA[
	'',
		// Show items
		array('select', 'favourite_item_ask', array($txt['favourite_item_disabled'], $txt['favourite_item_profile'], $txt['favourite_item_registration'], $txt['favourite_item_both'])),
		array('check', 'favourite_item_required'),
		array('check', 'favourite_item_show'),
]]></add>
		</operation>
	</file>
	
	<file name="$sourcedir/Profile-Modify.php">
		<operation>
			<search position="after"><![CDATA[		'date_registered' => array(]]></search>
			<add><![CDATA[
		'favourite_item' => array(
			'type' => 'select',
			'options' => favouriteitem(),
			'label' => $txt['favourite_item_label'],
		),]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[			'bday1', 'location', 'gender', 'hr',]]></search>
			<add><![CDATA[			'bday1', 'location', 'favourite_item', 'gender', 'hr',]]></add>
		</operation>
	</file>

	<file name="$sourcedir/Subs.php">
		<operation>
			<search position="end" />
			<add><![CDATA[
// Nice big array of countries!
function favouriteitem()
{
	$items = array(
		'00' => '',
		'1' => 'Item 1',				'3' => 'Item 3',					'5' => 'Item 5',
		'2' => 'Item 2',			'4' => 'Item 4',					'6' => 'Item 6',
]]></add>
		</operation>
	</file>

	<file name="$themedir/Display.template.php">
		<operation>
			<search position="after"><![CDATA[			// Is karma display enabled?  Total or +/-?]]></search>
			<add><![CDATA[			// Show the favourite they hail from!
			if (isset($message['member']['favourite_item']) && !empty($modSettings['favourite_item_show']) && !empty($message['member']['favourite_item']))
			{
				$items = favouriteitem();
				echo '
								<li class="gender">', $txt['favourite_item'], ': <img src="', $settings['images_url'], '/items/', $message['member']['favourite_item'], '.png" alt="', $message['member']['favourite_item'], '" title="', $items[$message['member']['favourite_item']], '" /></li>';
			}
]]></add>
		</operation>
	</file>
	
	<file name="$themedir/Profile.template.php">
		<operation>
			<search position="replace"><![CDATA[			// Always fun - select boxes!
			elseif ($field['type'] == 'select')
			{
				echo '
								<select name="', $key, '" id="', $key, '">';

				if (isset($field['options']))
				{
					// Is this some code to generate the options?
					if (!is_array($field['options']))
						$field['options'] = eval($field['options']);
					// Assuming we now have some!
					if (is_array($field['options']))
						foreach ($field['options'] as $value => $name)
							echo '
									<option value="', $value, '" ', $value == $field['value'] ? 'selected="selected"' : '', '>', $name, '</option>';
				}

				echo '
								</select>';
			}]]></search>
			<add><![CDATA[			// Always fun - select boxes!
			elseif ($field['type'] == 'select')
			{
				if ($key == 'favourite_item')
				{
					echo '
								<script type="text/javascript" language="JavaScript">
									function show_favourite_items()
									{
										document.images.items.src = document.forms.creator.favourite_item.options[document.forms.creator.favourite_item.selectedIndex].value != \'\' ? \'' . $settings['images_url'] . '/items/\' + document.forms.creator.favourite_item.options[document.forms.creator.favourite_item.selectedIndex].value + \'.png\' : \'' . $settings['images_url'] . '/items/blank.gif\';
									}
								</script>
								<select name="', $key, '" id="', $key, '" onchange="show_favourite_items()">';
								
							foreach ($field['options'] as $value => $name)
								echo '
									<option value="', $value, '" ', isset($context['member']['favourite_item']) &&  $context['member']['favourite_item'] == $value ? 'selected="selected"' : '', '>', $name, '</option>';
							
							echo '
								</select>
								<img id="items" src="', $settings['images_url'], '/', isset($context['member']['favourite_item']) && !empty($context['member']['favourite_item']) ? 'items/' . $context['member']['favourite_item'] . '.png': 'blank.gif', '" width="25" height="15" align="top" />';	
				}
				else
				{
					echo '
								<select name="', $key, '" id="', $key, '">';

					if (isset($field['options']))
					{
						// Is this some code to generate the options?
						if (!is_array($field['options']))
							$field['options'] = eval($field['options']);
						// Assuming we now have some!
						if (is_array($field['options']))
							foreach ($field['options'] as $value => $name)
								echo '
										<option value="', $value, '" ', $value == $field['value'] ? 'selected="selected"' : '', '>', $name, '</option>';
					}

					echo '
									</select>';
				}
			}]]></add>
		</operation>
	</file>	

	<file name="$themedir/Register.template.php">
		<operation>
			<search position="replace"><![CDATA[

	echo '
				</fieldset>
				<span class="botslice"><span></span></span>
			</div>';

	// If we have either of these, show the extra group.]]></search>
			<add><![CDATA[
	// If items is set for registration show it.
	if (!empty($modSettings['favourite_item_ask']) && ($modSettings['favourite_item_ask'] == 2 || $modSettings['favourite_item_ask'] == 3))
	{
		// Call the function that has all the item info
		$items = favouriteitem();

		echo '
					<script language="JavaScript" type="text/javascript">
						function showitems()
						{
							document.images.items.src = document.forms.registration.favourite.options[document.forms.registration.favourite.selectedIndex].value != \'\' ? \'' . $settings['default_theme_url'] . '/images/items/\' + document.forms.registration.favourite.options[document.forms.registration.favourite.selectedIndex].value + \'.png\' : \'' . $settings['default_theme_url'] . '/images/items/blank.gif\';
						}
					</script>
					<dl class="register_form" id="favourite_item">
						<dt><strong>', $txt['favourite_item_label'], ':</strong></dt>
						<dd>
							<select name="favourite" onchange="showitems()">
								<option value=""></option>';

					// Loop and show the drop down.
					foreach ($items as $key => $name)
						echo '
								<option value="', $key, '">', $name, '</option>';

		echo '
							</select>
							<img id="items" src="', $settings['default_theme_url'], '/images/blank.gif" width="25" height="15" align="top" />
						</dd>
					</dl>';
	}
	echo '
				</fieldset>
				<span class="botslice"><span></span></span>
			</div>';	
	
	
]]></add>
		</operation>
	</file>
	
	<file name="$sourcedir/Register.php">
		<operation>
			<search position="before"><![CDATA[// Things we don't do for people who have already confirmed their OpenID allegances via register.]]></search>
			<add><![CDATA[
	// Convert the $_POST['favourite'] to $_POST['default_options']['favourite']
	if (isset($_POST['favourite']))
	{
		$_POST['default_options']['favourite'] = $_POST['favourite'];

		// Check if it's required to select location
		if (!empty($modSettings['favourite_item_required']) && empty($_POST['default_options']['favourite']))
			fatal_lang_error('favourite_item_error_required', false);
	}
]]></add>
		</operation>
		<operation>
			<search position="before"><![CDATA[// If COPPA has been selected then things get complicated, setup the template.]]></search>
			<add><![CDATA[	
			
	// favourite item Mod smfhacks.com		
	if (isset($_POST['favourite']))
	$smcFunc['db_query']('', '
		UPDATE {db_prefix}members
		SET favourite_item = {string:favourite}
		WHERE id_member = {int:memid}',
		array(
			'favourite' => $_POST['favourite'],
			'memid' => $memberID,
		)
	);
	// End favourite item Mod smfhacks.com
]]></add>

		</operation>		
	</file>

</modification>
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console