Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: NIAB - lokakuu 15, 2013, 11:16:07 IP

Otsikko: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:16:07 IP
Which file do I find to edit the cat_bar shown in this picture..



I've managed to find it for other profile pages, just cant find it for post history

Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 15, 2013, 11:25:23 IP
Profile.template.php

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

echo '
<div class="cat_bar">
<h3 class="catbg">
', (!isset($context['attachments']) && empty($context['is_topics']) ? $txt['showMessages'] : (!empty($context['is_topics']) ? $txt['showTopics'] : $txt['showAttachments'])), ' - ', $context['member']['name'], '
</h3>
</div>
<div class="pagesection">
<span>', $txt['pages'], ': ', $context['page_index'], '</span>
</div>';


But note that the same code handles Show Posts, Show Topics, and Show Attachments cat_bars.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:36:33 IP
That section of code wasn't there, so I added it and the result happened.

Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 15, 2013, 11:38:13 IP
I plucked that straight from an unmodified 2.0.5 install starting line 330. I have no idea what the heck you've done to your code.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:40:00 IP
lol, Im not sure either. It only shows on that one page... it baffles me.

I'll keep snooping though, I normally find out what I need - or in this case; what ive done
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:48:11 IP
I'm using 2.0.4 SMF, any chance it's in another place?
Otsikko: Re: How to edit ...
Kirjoitti: Burke ♞ Knight - lokakuu 15, 2013, 11:49:04 IP
What theme are you using?
Does it have it's own copy of that file?
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:50:43 IP
Using my own theme design. It uses the Profile.template.php from the default theme folder
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 15, 2013, 11:54:43 IP
This is my showPosts Template

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

// Button shortcuts
$quote_button = create_button('quote.gif', 'reply_quote', 'quote', 'align="middle"');
$reply_button = create_button('reply_sm.gif', 'reply', 'reply', 'align="middle"');
$remove_button = create_button('delete.gif', 'remove_message', 'remove', 'align="middle"');
$notify_button = create_button('notify_sm.gif', 'notify_replies', 'notify', 'align="middle"');

// Are we displaying posts or attachments?
if (!isset($context['attachments']))
{
// For every post to be displayed, give it its own div, and show the important details of the post.
foreach ($context['posts'] as $post)
{
echo'
<div class="custom_borderframe"><div class="custom_borderoutline"><div class="custom_bordercolor"><div class="custom_borderbackground" style="padding:2px;">';
echo '
<div class="topic">
<div class="', $post['alternate'] == 0 ? 'windowbg2' : 'windowbg', ' core_posts" style="background:transparent;">

<div class="content">
<div class="counter">', $post['counter'], '</div>
<div class="topic_details">
<h5><strong><a href="', $scripturl, '?board=', $post['board']['id'], '.0">', $post['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $post['topic'], '.', $post['start'], '#msg', $post['id'], '">', $post['subject'], '</a></strong></h5>
<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $post['time'], '&nbsp;&#187;</span>
</div>
<div class="list_posts">';

if (!$post['approved'])
echo '
<div class="approve_post">
<em>', $txt['post_awaiting_approval'], '</em>
</div>';

echo '
', $post['body'], '
</div>
</div>';

if ($post['can_reply'] || $post['can_mark_notify'] || $post['can_delete'])
echo '
<div class="floatright">
<ul class="reset smalltext quickbuttons">';

// If they *can* reply?
if ($post['can_reply'])
echo '
<li class="reply_button"><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span>', $txt['reply'], '</span></a></li>';

// If they *can* quote?
if ($post['can_quote'])
echo '
<li class="quote_button"><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span>', $txt['quote'], '</span></a></li>';

// Can we request notification of topics?
if ($post['can_mark_notify'])
echo '
<li class="notify_button"><a href="', $scripturl, '?action=notify;topic=', $post['topic'], '.', $post['start'], '"><span>', $txt['notify'], '</span></a></li>';

// How about... even... remove it entirely?!
if ($post['can_delete'])
echo '
<li class="remove_button"><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');"><span>', $txt['remove'], '</span></a></li>';

if ($post['can_reply'] || $post['can_mark_notify'] || $post['can_delete'])
echo '
</ul>
</div>';


echo '
<br class="clear" />
</div>
</div>';
echo'</div></div></div></div>';
}

}
else
{
echo '
<table border="0" width="100%" cellspacing="1" cellpadding="2" class="table_grid" align="center">
<thead>
<tr class="titlebg">
<th class="first_th lefttext" scope="col" width="25%">
<a href="', $scripturl, '?action=profile;u=', $context['current_member'], ';area=showposts;sa=attach;sort=filename', ($context['sort_direction'] == 'down' && $context['sort_order'] == 'filename' ? ';asc' : ''), '">
', $txt['show_attach_filename'], '
', ($context['sort_order'] == 'filename' ? '<img src="' . $settings['images_url'] . '/sort_' . ($context['sort_direction'] == 'down' ? 'down' : 'up') . '.gif" alt="" />' : ''), '
</a>
</th>
<th scope="col" width="12%">
<a href="', $scripturl, '?action=profile;u=', $context['current_member'], ';area=showposts;sa=attach;sort=downloads', ($context['sort_direction'] == 'down' && $context['sort_order'] == 'downloads' ? ';asc' : ''), '">
', $txt['show_attach_downloads'], '
', ($context['sort_order'] == 'downloads' ? '<img src="' . $settings['images_url'] . '/sort_' . ($context['sort_direction'] == 'down' ? 'down' : 'up') . '.gif" alt="" />' : ''), '
</a>
</th>
<th class="lefttext" scope="col" width="30%">
<a href="', $scripturl, '?action=profile;u=', $context['current_member'], ';area=showposts;sa=attach;sort=subject', ($context['sort_direction'] == 'down' && $context['sort_order'] == 'subject' ? ';asc' : ''), '">
', $txt['message'], '
', ($context['sort_order'] == 'subject' ? '<img src="' . $settings['images_url'] . '/sort_' . ($context['sort_direction'] == 'down' ? 'down' : 'up') . '.gif" alt="" />' : ''), '
</a>
</th>
<th class="last_th lefttext" scope="col">
<a href="', $scripturl, '?action=profile;u=', $context['current_member'], ';area=showposts;sa=attach;sort=posted', ($context['sort_direction'] == 'down' && $context['sort_order'] == 'posted' ? ';asc' : ''), '">
', $txt['show_attach_posted'], '
', ($context['sort_order'] == 'posted' ? '<img src="' . $settings['images_url'] . '/sort_' . ($context['sort_direction'] == 'down' ? 'down' : 'up') . '.gif" alt="" />' : ''), '
</a>
</th>
</tr>
</thead>
<tbody>';

// Looks like we need to do all the attachments instead!
$alternate = false;
foreach ($context['attachments'] as $attachment)
{
echo '
<tr class="', $attachment['approved'] ? ($alternate ? 'windowbg' : 'windowbg2') : 'approvebg', '">
<td><a href="', $scripturl, '?action=dlattach;topic=', $attachment['topic'], '.0;attach=', $attachment['id'], '">', $attachment['filename'], '</a>', !$attachment['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : '', '</td>
<td align="center">', $attachment['downloads'], '</td>
<td><a href="', $scripturl, '?topic=', $attachment['topic'], '.msg', $attachment['msg'], '#msg', $attachment['msg'], '" rel="nofollow">', $attachment['subject'], '</a></td>
<td>', $attachment['posted'], '</td>
</tr>';
$alternate = !$alternate;
}

// No posts? Just end the table with a informative message.
if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
echo '
<tr>
<td class="tborder windowbg2 padding centertext" colspan="4">
', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
</td>
</tr>';

echo '
</tbody>
</table>';
}

// Show more page numbers.
echo '
<div class="pagesection" style="margin-bottom: 0;">
<span>', $txt['pages'], ': ', $context['page_index'], '</span>
</div>';
}


Now where does it have catbg for  "Show Posts"

Otsikko: Re: How to edit ...
Kirjoitti: Burke ♞ Knight - lokakuu 15, 2013, 11:56:06 IP
If have own theme, it usually would be better to copy any files you wish to edit, from the default to your custom theme, so you would have the default to revert to if mess up. That is what I always do, and recommend.

Also:
Always be sure to back up any files before you edit them.

Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 15, 2013, 11:59:54 IP
Like I said, I have no idea what the heck you've done to your file, because the 2.0.4 and 2.0.5 profile templates are identical.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 16, 2013, 12:04:30 AP
Found it.. Not sure why this is there


// Handy shortcut.
$tab_context = &$menu_context['tab_data'];

echo '
<div class="cat_bar">
<h3 class="catbg"> test';

// Exactly how many tabs do we have?
foreach ($context['tabs'] as $id => $tab)
{
// Can this not be accessed?
if (!empty($tab['disabled']))
{
$tab_context['tabs'][$id]['disabled'] = true;
continue;
}

// Did this not even exist - or do we not have a label?
if (!isset($tab_context['tabs'][$id]))
$tab_context['tabs'][$id] = array('label' => $tab['label']);
elseif (!isset($tab_context['tabs'][$id]['label']))
$tab_context['tabs'][$id]['label'] = $tab['label'];

// Has a custom URL defined in the main admin structure?
if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
$tab_context['tabs'][$id]['url'] = $tab['url'];
// Any additional paramaters for the url?
if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
// Has it been deemed selected?
if (!empty($tab['is_selected']))
$tab_context['tabs'][$id]['is_selected'] = true;
// Does it have its own help?
if (!empty($tab['help']))
$tab_context['tabs'][$id]['help'] = $tab['help'];
// Is this the last one?
if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
$tab_context['tabs'][$id]['is_last'] = true;
}


In Generic Menu template... handy? :/
Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 16, 2013, 12:11:55 AP
Ah, yes, I forgot there are two cat-bars in the show posts area, I pointed you to the one you can actually safely change. The other one you probably shouldn't because it affects everywhere with the generic menu, which is the profile, the PM area, the moderation panel and the admin panel.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 16, 2013, 12:29:52 AP
Yeah I know, I've only modified what I need and left what doesn't need changes (Currently)

Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 16, 2013, 12:36:46 AP
And does it work *everywhere* the generic template works? That's the danger of touching the generic template - it can so easily break things.

Oh, and you should also see what happens if you switch to sidebar mode too. You may not like the result either.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 16, 2013, 12:38:19 AP
I've removed the ability to switch the sidebar around. Was a pain making small tweaks to everything just to accommodate its functionality. And it works everywhere :)
Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 16, 2013, 12:45:47 AP
You even went as far as 1) removing the option from the profile template and 2) will be ensuring that users don't have a latent setting in their preferences? It's not just the << and >> buttons you need to watch out for.
Otsikko: Re: How to edit ...
Kirjoitti: NIAB - lokakuu 16, 2013, 12:47:43 AP
It's still there, just for admins though. So if  I want to re-enable it later there wont be too much trouble. The main issue with it is that the boxes I use around everything kind of mess up their width and layout. So for now it isn't needed.
Otsikko: Re: How to edit ...
Kirjoitti: Arantor - lokakuu 16, 2013, 08:53:31 AP
Actually it is still possible for non admins to set it but I doubt your users would know how.