Custom Greeting

Started by Diego Andrés, September 08, 2008, 03:05:09 AM

Previous topic - Next topic

Marcus Forsberg

Quote from: Bobn on March 14, 2010, 06:02:38 PM
Quote from: Nas on March 09, 2010, 02:45:47 PM
Just as an update on this one, I'm going to upgrade it for RC3 during the coming couple of weeks. Hold on ;)

What about Rc2?

Uh, no, RC2 is outdated, buggy, and insecure...

Quote from: Eclipse16V on March 15, 2010, 01:49:43 AM
Nice Mod

Please update it for SMF 2.0RC3  ;)

Thanks

Will do within the next few weeks.

Marcus Forsberg

Went ahead and updated this. It should now work on SMF 2.0 RC3. Let me know of any issues.

Bobn

Will this work on rc2?  I am told that if I want to upgrade I will loos all my mods and settings in all my themes,,, what a pain.  love this mod

Marcus Forsberg

It is not tested on RC2, however if you try to emulate SMF 2.0 RC3 in your package manager it should work.

Bobn

Quote from: Nas on March 16, 2010, 11:44:55 AM
It is not tested on RC2, however if you try to emulate SMF 2.0 RC3 in your package manager it should work.

Thanks,, I dont see that in the packages,, Also I dont know the software well enough.

Marcus Forsberg

To emulate a version, go to your package managers and look at the bottom. You'll see an "Advanced" link to the right, just below the list of installed packages. Click on that, and then type 'SMF 2.0 RC3' (without the quotes). That should allow you to install this mod.

~DS~

Cool, what was fixed in this release? What's the changelogs?
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Marcus Forsberg

Only made some minor code cleanup and added RC3 support. No new functions at this point. I may add some after the release of SimpleDesk, taken that there actually is something to add. Ideas? ;)

Bobn

Quote from: Nas on March 16, 2010, 11:53:37 AM
To emulate a version, go to your package managers and look at the bottom. You'll see an "Advanced" link to the right, just below the list of installed packages. Click on that, and then type 'SMF 2.0 RC3' (without the quotes). That should allow you to install this mod.

Worked! How can I manually install this mode on other templates sir?

~DS~

It has potential yes, How about customizing time?
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Marcus Forsberg

Quote from: Bobn on March 16, 2010, 12:05:22 PM
Quote from: Nas on March 16, 2010, 11:53:37 AM
To emulate a version, go to your package managers and look at the bottom. You'll see an "Advanced" link to the right, just below the list of installed packages. Click on that, and then type 'SMF 2.0 RC3' (without the quotes). That should allow you to install this mod.

Worked! How can I manually install this mode on other templates sir?

If the edit used for the default theme (Curve) doesn't work on your theme, i.e the lines are different, you need to find the line in ./Themes/{your_theme}/index.template.php that prints the default greeting, and replace the greeting code there with ', $context['greeting'], '.

Quote from: Dismal Shadow on March 16, 2010, 12:08:08 PM
It has potential yes, How about customizing time?

That could indeed be an idea.

Bobn

Quote from: Nas on March 16, 2010, 12:09:39 PM
Quote from: Bobn on March 16, 2010, 12:05:22 PM
Quote from: Nas on March 16, 2010, 11:53:37 AM
To emulate a version, go to your package managers and look at the bottom. You'll see an "Advanced" link to the right, just below the list of installed packages. Click on that, and then type 'SMF 2.0 RC3' (without the quotes). That should allow you to install this mod.

Worked! How can I manually install this mode on other templates sir?

If the edit used for the default theme (Curve) doesn't work on your theme, i.e the lines are different, you need to find the line in ./Themes/{your_theme}/index.template.php that prints the default greeting, and replace the greeting code there with ', $context['greeting'], '.

Quote from: Dismal Shadow on March 16, 2010, 12:08:08 PM
It has potential yes, How about customizing time?

That could indeed be an idea.

Could you look at my index.template.php?

<?php
// Version: 2.0 RC2; index

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context$settings$options$txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '2.0 RC2';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as opposed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status separate from topic icons? */
$settings['separate_sticky_lock'] = true;

/* Does this theme use the strict doctype? */
$settings['strict_doctype'] = false;

/* Does this theme use post previews on the message index? */
$settings['message_index_preview'] = false;

/* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */
$settings['require_theme_strings'] = false;
}

// The main sub template above the content.
function template_html_above()
{
global $context$settings$options$scripturl$txt$modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
<meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
<meta name="description" content="'
$context['page_title_html_safe'], '" />
<meta name="keywords" content="'
$context['meta_keywords'], '" />
<title>'
$context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />'
;

// Present a canonical url for search engines to prevent duplicate content in their indices.
if (!empty($context['canonical_url']))
echo '
<link rel="canonical" href="'
$context['canonical_url'], '" />';

// The ?rc2 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/index'$context['theme_variant'], '.css?rc2" />
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/css/print.css?rc2" media="print" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="'
$scripturl'?action=help" />
<link rel="search" href="' 
$scripturl '?action=search" />
<link rel="contents" href="'
$scripturl'" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
echo '
<link rel="alternate" type="application/rss+xml" title="'
$context['forum_name_html_safe'], ' - '$txt['rss'], '" href="'$scripturl'?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="'
$scripturl'?board='$context['current_board'], '.0" />';

// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}

// Some browsers need an extra stylesheet due to bugs/compatibility issues.
foreach (array('ie7''ie6''firefox''webkit') as $cssfix)
if ($context['browser']['is_' $cssfix])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/'$cssfix'.css" />';

// RTL languages require an additional stylesheet.
if ($context['right_to_left'])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/rtl.css" />';

echo '
<script type="text/javascript" src="'
$settings['default_theme_url'], '/scripts/script.js?rc2"></script>
<script type="text/javascript" src="'
$settings['theme_url'], '/scripts/theme.js?rc2"></script>
<script type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "'
$settings['theme_url'], '";
var smf_default_theme_url = "'
$settings['default_theme_url'], '";
var smf_images_url = "'
$settings['images_url'], '";
var smf_scripturl = "'
$scripturl'";
var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
var smf_charset = "'
$context['character_set'], '";'$context['show_pm_popup'] ? '
var fPmPopup = function ()
{
if (confirm("' 
$txt['show_personal_messages'] . '"))
window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm");
}
addLoadEvent(fPmPopup);' 
'''
var ajax_notification_text = "'
$txt['ajax_in_progress'], '";
var ajax_notification_cancel_text = "'
$txt['modify_cancel'], '";
// ]]></script>'
;

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'];

echo '
</head>
<body>'
;
}

function 
template_body_above()
{
global $context$settings$options$scripturl$txt$modSettings;

echo '
<div id="mainframe"'
, !empty($settings['forum_width']) ? ' style="width: ' $settings['forum_width'] . '"' '''>
 <div id="header">
  <div id="head-l">
  <div id="head-r">
  <div id="userarea" class="clearfix">
  <table width="100%">'
;
if (!empty($context['user']['avatar']))
 echo '<div id="my-avatar" class="clearfix">'.$context['user']['avatar']['image'].'</div>';
if ($context['user']['is_logged']){

 echo '<b>'$txt['hello_member'], ' '$context['user']['name'], '</b><br />';

  // Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
  echo $txt['msg_alert_you_have'], ' <a href="'$scripturl'?action=pm">'$context['user']['messages'], ' '$context['user']['messages'] != $txt['msg_alert_messages'] : $txt['message_lowercase'], '</a>'$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

echo '<a href="'$scripturl'?action=unread">'$txt['unread_since_visit'], '</a><br /><a href="'$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a><br />';}
 // Otherwise they're a guest - this time ask them to either register or login - lazy bums...
  else
{
  echo sprintf($txt['welcome_guest'], $txt['guest_title']);
 echo '
  <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/scripts/sha1.js"></script>
 <form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>
<input type="text" name="user"  size="10" />
<input type="password" name="passwrd"  size="10" />
<input type="submit" value="'
$txt['login'], '" />
<input type="hidden" name="hash_passwrd" value="" />
 </form>'
$context['current_time'],'<br />';
 
 
 }
 
 // Begin Ad Seller Pro Location - Welcome Area/User Information Box

global $sourcedir;
include_once 
$sourcedir "/adseller2.php";

$adSellerAdData =  ShowAdLocation(13);
if (
$adSellerAdData != false)
{
echo '</td>';
echo '<td class="windowbg">';
echo $adSellerAdData;

}

// End Ad Seller Pro Location - Welcome Area/User Information Box

echo '</table>
  </div>
<div id="searcharea">
  <form action="'
$scripturl'?action=search2" method="post" accept-charset="'$context['character_set'], '">
  <input type="text" name="search" value="'
$txt['search'], '..." onfocus="this.value = \'\';" onblur="if(this.value==\'\') this.value=\''$txt['search'], '...\';" /> ';

// Search within current topic?
if (!empty($context['current_topic']))
 echo '
<input type="hidden" name="topic" value="'
$context['current_topic'], '" />';

// If we're on a certain board, limit it to this board ;).
  elseif (!empty($context['current_board']))
 echo '
 <input type="hidden" name="brd['
$context['current_board'], ']" value="'$context['current_board'], '" />';
 echo '
 </form>
  </div>'
;

  
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news'])){
echo '<div id="news">
  <b>'
$txt['news'], ':</b> '$context['random_news_line'], '</div>';}
  echo 
'
<a href="'
.$scripturl.'" title=""><span id="logo"> </span></a>';
echo '
</div>
  </div>
</div>'
;
  echo 
'
  <div id="toolbar">
'
,template_menu(),'
  </div>
  <div id="bodyarea">'
;
theme_linktree2();


// Begin Ad Seller Pro Location - Overall Header

global $sourcedir;
include_once 
$sourcedir "/adseller2.php";

$adSellerAdData =  ShowAdLocation(1);
if (
$adSellerAdData != false)
{
echo $adSellerAdData;
}

// End Ad Seller Pro Location - Overall Header

// Begin Ad Seller Pro Location - Left Side of the Forum

echo '<table border="0" width="100%">
<tr>'
;

global 
$sourcedir;
include_once 
$sourcedir "/adseller2.php";

$adSellerAdData =  ShowAdLocation(9);
if (
$adSellerAdData != false)
{
echo '<td valign="top">';

echo $adSellerAdData;

echo '</td>';
}



echo 
'<td valign="top" width="100%">';

// End Ad Seller Pro Location - Left Side of the Forum

}

function 
template_body_below()
{
global $context$settings$options$scripturl$txt;

// Begin Ad Seller Pro Location - Right Side of the Forum
echo '</td>';
global 
$sourcedir;
include_once 
$sourcedir "/adseller2.php";

$adSellerAdData =  ShowAdLocation(10);
if (
$adSellerAdData != false)
{
echo '<td valign="top">';

echo $adSellerAdData;

echo '</td>';
}
echo 
'</tr></table>';
// End Ad Seller Pro Location - Right Side of the Forum

echo '
</div>'
;


// Begin Ad Seller Pro Location - Overall Footer

global $sourcedir;
include_once 
$sourcedir "/adseller2.php";

$adSellerAdData =  ShowAdLocation(2);
if (
$adSellerAdData != false)
{
echo $adSellerAdData;
}

// End Ad Seller Pro Location - Overall Footer

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
echo '
 <div id="footer">
 <div id="foot-l">
 <div id="foot-r">
 <div id="footerarea" class="smalltext">
<div class="right">'
theme_copyright(), ' | <a id="button_xhtml" href="http://validator.w3.org/check/referer" target="_blank" class="new_win" title="'$txt['valid_xhtml'], '"><span>XHTML</span></a> | <a id="button_rss" href="'$scripturl '?type=rss;action=.xml" class="new_win"><span>RSS</span></a> | <a id="button_wap2" href="'$scripturl '?wap2" class="new_win"><span>WAP2</span></a>
 </div>
 <div class="left">
  <strong>Anecdota</strong> by <a href="http://www.jpr62.com/theme/index.php"><strong>Crip</strong></a>
 </div>'
;

// Show the load time?
if ($context['show_load_time'])
echo '
<p class="smalltext" id="show_loadtime">'
$txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';

echo '
  </div>
 </div>
</div>
 </div>'
;
}

function 
template_html_below()
{
global $context$settings$options$scripturl$txt$modSettings;

echo '
</div>
</body></html>'
;
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree2()
{
global $context$settings$options;

echo '
  <div id="linktree">'
;

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '">' $tree['name'] . '</a>' $tree['name'];

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo '&nbsp;&#38;#187;&nbsp;';
}

echo '
</div>'
;
}

function 
theme_linktree()
{
return;
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context$settings$options$scripturl$txt;
echo '
  <div id="menumain">
<ul>'
;
foreach ($context['menu_buttons'] as $act => $button)
 echo '<li><a '$button['active_button'] ? ' class="current"' '' ' href="'$button['href'], '"><span>'$button['title'], '</span></a></li>';

echo '
  </ul>
</div>'
;
}

// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$strip_options = array())
{
global $settings$context$txt$scripturl;

if (!is_array($strip_options))
$strip_options = array();

// Right to left menu should be in reverse order.
if ($context['right_to_left'])
$button_strip array_reverse($button_striptrue);

// Create the buttons...
$buttons = array();
foreach ($button_strip as $key => $value)
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '<li' . (isset($value['active']) ? ' class="active"' '') . '><a href="' $value['url'] . '"' . (isset($value['custom']) ? ' ' $value['custom'] : '') . '><span>' . (isset($value['active']) ? '<em>' '') . $txt[$value['text']] . (isset($value['active']) ? '</em>' '') . '</span></a></li>';

// No buttons? No button strip either.
if (empty($buttons))
return;

// Make the last one, as easy as possible.
$list_item = array('<li>''<li class="active">');
$active_item = array('<li class="last">''<li class="active last">');

$buttons[count($buttons) - 1] = str_replace($list_item$active_item$buttons[count($buttons) - 1]);

echo '
<div class="buttonlist'
$direction != 'top' '_bottom' '''"', (empty($buttons) ? ' style="display: none;"' ''), (!empty($strip_options['id']) ? ' id="' $strip_options['id'] . '"'''), '>
<ul class="reset clearfix">
'
implode(''$buttons), '
</ul>
</div>'
;
}

?>

Marcus Forsberg

This line:

echo '<b>', $txt['hello_member'], ' ', $context['user']['name'], '</b><br />';

Will need $context['greeting']. Like this:

echo $context['greeting'], '<br />';

Bobn

Quote from: Nas on March 16, 2010, 12:30:46 PM
This line:

echo '<b>', $txt['hello_member'], ' ', $context['user']['name'], '</b><br />';

Will need $context['greeting']. Like this:

echo $context['greeting'], '<br />';

Yea! Yea! Works great! Thanks!!   Anyway to bold the greeting?

Marcus Forsberg

To bold:

echo '<strong>', $context['greeting'], '</strong><br />';

Bobn

Quote from: Nas on March 16, 2010, 12:40:49 PM
To bold:

echo '<strong>', $context['greeting'], '</strong><br />';

Thanks! Your awesome! This is one of my favorite mods :)

Marcus Forsberg


~DS~

Quote from: Bobn on March 16, 2010, 12:47:12 PM
Quote from: Nas on March 16, 2010, 12:40:49 PM
To bold:

echo '<strong>', $context['greeting'], '</strong><br />';

Thanks! Your awesome! This is one of my favorite mods :)
Try on this for size
"What are you doing awake? It's late, Dismal Shadow"
The forum orders me.  ;D
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Eclipse16V

Thanks Nas

Work fine on RC3

German Lang
$txt['up_late_arent_we'] = 'So spät noch auf';
$txt['are_you_the_early_bird'] = 'So früh schon auf';
$txt['good_morning'] = 'Guten Morgen';
$txt['good_afternoon'] = 'Guten Tag';
$txt['good_evening'] = 'Guten Abend';
$txt['shouldnt_you_be_going_to_bed_soon'] = 'Zeit ins Bett zu gehen';
$txt['cgdt_message1'] = 'CGDT Grusstext 1 <div class="smalltext">Wird angezeigt von Mitternacht bis 5:59</div>';
$txt['cgdt_message2'] = 'CGDT Grusstext 2 <div class="smalltext">Wird angezeigt von 6:00 bis 6:59</div>';
$txt['cgdt_message3'] = 'CGDT Grusstext 3 <div class="smalltext">Wird angezeigt von 7:00 bis 11:59</div>';
$txt['cgdt_message4'] = 'CGDT Grusstext 4 <div class="smalltext">Wird angezeigt von 12:00 bis 17:59</div>';
$txt['cgdt_message5'] = 'CGDT Grusstext 5 <div class="smalltext">Wird angezeigt von 18:00 bis 21:59</div>';
$txt['cgdt_message6'] = 'CGDT Grusstext 6 <div class="smalltext">Wird angezeigt von 22:00 bis 23:59</div>';
$txt['cgdt_enable'] = 'Eigene Grusstexte aktivieren <div class="smalltext">Dieses Mod zeigt verschiedene Grusstexte im Kopf des Forums je nach Tageszeit. <br /> Grusstexte sind unten angezeigt.</div>';
I worked with:
SMF 2 in German

Shop:
SID Giessen

~DS~

Got another bug for you, Nas.
I don't know how to duplicate this, but it appear on the error log from time to time.
8: Undefined index: greeting
File: /home/user/public_html/forum.com/Themes/default/index.template.php
Line: 250
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Advertisement: