Gönderen Konu: Konu İçi ve Mesaj Listesi Butonlarıina Icon Atama  (Okunma sayısı 704 defa)

Çevrimiçi orhan

  • Yönetici
  • Trade Sayısı: (0)
  • *
  • İleti: 385
  • Karma +19/-1
  • Cinsiyet: Bay
    • Profili Görüntüle
    • webtiryaki.com
Malesef smf nin mantigini anlamak yerine her gordügümüzü sitemize uygulamaya calisiyoruz sonrada yakiniyoruz su hata bu hata diye ben size simdi bu isin mantigini anlatmaya calisicam(Bu arada türkiyeye geldigimde ilk isim Q kilavya almak olacak yazi berbat)
neyse konumuza donelim smf temasinin iskeletini index.template.php olusturur diger dosyalar yardimci dosyalardir o yüzden haricde yani olan kodun haricinde diger dosyalara kod atadiginizda ayr ayri güc alanlari olüstürmüs olursunuz bu dersimizde bunu anlatmaya calisacagim basit sekilde saten var olan buton sistemine ikon atayacagiz


resimdeki yerlere


simdi index.template.php mizi aciyoruz

Bu kisim ikonlarin atandigi kisim

Kod: [Seç]
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))
{
echo '
<ul>';

foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li>
<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
<span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span>
</a>';
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{
echo '
<ul>';

foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
<span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span>
</a>
</li>';

echo '
</ul>';
}

echo '
</li>';
}
echo '
</ul>';
}
echo '
</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();

// List the buttons in reverse order for RTL languages.
if ($context['right_to_left'])
$button_strip = array_reverse($button_strip, true);

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

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

// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

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

?>

Burayi biraz inceleyelim

Bu kod menü alanini olusturuyor(menulere ikon atamayi daha sonraki dersimizde anlaticam)

Kod: [Seç]
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))
{
echo '
<ul>';

foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li>
<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
<span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span>
</a>';
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{
echo '
<ul>';

foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
<span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span>
</a>
</li>';

echo '
</ul>';
}

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

echo '
</ul>
</div>';
}
Bu kisimsa Diger Alanlardaki Buton Tanimlamalari(BoardIndex.template.php  Display.template.php MessageIndex.template.php )
Kod: [Seç]
// 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();

// List the buttons in reverse order for RTL languages.
if ($context['right_to_left'])
$button_strip = array_reverse($button_strip, true);

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

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

// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

echo '
<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
<ul>',
implode('', $buttons), '
</ul>
</div>';
}
Simdi biz Menu haricindeki var olan butonlara ikon atayalim bunun icin
bulun
Kod: [Seç]
// Create the buttons...
$buttons = array();
foreach ($button_strip as $key => $value)
{
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '
<li><a' . (isset($value['id']) ? ' id="button_strip_' . $value['id'] . '"' : '') . ' class="button_strip_' . $key . (isset($value['active']) ? ' active' : '') . '" href="' . $value['url'] . '"' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a></li>';
}
Degistirin
Kod: [Seç]
// Create the buttons...
$buttons = array();
$buttonfaces = array('markread' => 'mark_read.png', 'new_topic' => 'new_topic.png', 'post_poll' => 'add_poll.png', 'notify' => (isset($context['is_marked_notify']) && $context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'new_poll' => 'add_poll.png',
'reply' => 'reply.png', 'add_poll' => 'add_poll.png', 'mark_unread' => 'mark_unread.png', 'send' => 'send.png', 'print' => 'print.png',
'move' => 'move.png', 'delete' => 'remove.png', 'lock' => 'lock.png', 'sticky' => 'sticky.png', 'merge' => 'merge.png', 'calendar' => 'calendar.png',
'view_all_members' => 'members.png', 'mlist_search' => 'search.png',
'im_reply_all' => 'im_reply_all.png', 'im_delete_conversation' => 'im_delete_conversation.png',
'post_event' => 'calendarpe.png');
foreach ($button_strip as $key => $value)
{
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '
<li><a' . (isset($value['id']) ? ' id="button_strip_' . $value['id'] . '"' : '') . ' class="button_strip_' . $key . (isset($value['active']) ? ' active' : '') . '" href="' . $value['url'] . '"' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . (array_key_exists($key, $buttonfaces) && ($settings['use_image_buttons'] == 1 || $settings['use_image_buttons'] == 2) ? '<img src="' . $settings['images_url'] . '/buttons/' . $buttonfaces[$key] . '" alt="' . $txt[$value['text']]. '"  title="' . $txt[$value['text']]. '" />' : '') . (!array_key_exists($key, $buttonfaces) || $settings['use_image_buttons'] != 2 ? $txt[$value['text']] : '') . '</span></a></li>';
}
Bul
Kod: [Seç]
// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

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

Degis

Kod: [Seç]
// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

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

// Creates an image/text button
function create_buttons($name, $alt, $label = '', $custom = '', $force_use = false)
{
global $settings, $txt, $context;

if (!$settings['use_image_buttons'])
return '<span>'. $txt[$alt].'</span>';
elseif ($settings['use_image_buttons'] == 1)
return '<span><img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" title="' . $txt[$alt] . '" ' . $custom . ' />' . ($label != '' ? '<strong>' . $txt[$label] . '</strong>' : ''). '</span>';
elseif ($settings['use_image_buttons'] == 2)
return '<img src="' . $settings['images_url'] . '/buttons/' . $name . '" alt="' . $txt[$alt] . '" title="' . $txt[$alt] . '" ' . $custom . ' />';
else
return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" title="' . $txt[$alt] . '" ' . $custom . ' />';
}

Bu kadar

simdi
index.css kucük bir ayar yapalim

bu kodu en alta ekliyoruz

Kod: [Seç]
.buttonlist ul li a span img
{
margin: 2px 2px 0 0;
float: left;
}
Bukadar basit ben ikonlari vermiyorum herkesin zevki farkli su siteden istediginiz ikonu indirip images-buttons kilasorune atin
http://www.iconfinder.com/
buda yaptiktan sonraki goruntusu





Ben sadece mantigini göserdim Siz Daha iyisini yapabilirsiniz
« Son Düzenleme: 13 Mar 2013, 11:55:40 Gönderen: orhan »