Is there a way to have a different layout for first post?

Started by Xarcell, August 16, 2010, 07:50:37 AM

Previous topic - Next topic

Xarcell

Quote from: IchBin™ on August 22, 2010, 06:31:47 PM
It's most likely because you have put the style tags outside of the function Xarcell. Looks like it's not possible to add to the $context['html_headers'] inside the template though. I would either move it to the index.template.php file, or add it to the Display.php source file. I'm betting that is the cause of the errors that you're having. Trying removing all the code before the function and see if that fixes your problems.

I'm trying to understand what your saying, but I don't. I tried googling, but that didn't help either. Your not talking about the css, right?

If your talking about the quick modify form tags, they were already outside the function.

Can you give me an example of what a style is?

Xarcell

Ok, I figured out why I could not quick modify post. It was the topic rating code I added to it.

What I done to add the topic rating was I took this code:

       echo '
<div class="cat_bar">
<h3 class="catbg">
<img src="', $message['icon_url'] . '" alt="" border="0" style="margin-top: 8px" />
<span id="author">( ', $context['num_views'], ' ) Times This Article Has Been Read - ';

// How about... even... remove it entirely?!
if ($message['can_remove'])
echo '
[ <a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');">', $txt['remove'], '</a> ]</span>
</h3>

</div>';


and applied the topic rating and got this:
       echo '
<div class="cat_bar">
<h3 class="catbg">
<img src="', $message['icon_url'] . '" alt="" border="0" style="margin-top: 8px" />
<span id="author">( ', $context['num_views'], ' ) Times This Article Has Been Read - ';

// How about... even... remove it entirely?!
if ($message['can_remove'])
echo '
[ <a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');">', $txt['remove'], '</a> ]', (!empty($modSettings['rateTopic_allow']) && !empty($context['rating_average'])) ?  ' - with ( '.$context['rating_number'].' ) votes &nbsp;<span class="inline-rating"><ul class="star-rating"><li class="current-rating" style="width: '.($context['rating_average'] / 5 * 100).'%"></li></ul></span>' : '' , '</span>';

//Topic Rating
if( !empty($modSettings['rateTopic_allow']) && !empty($context['rateTopic_board_enable']) && !$context['user']['is_guest'] ){
echo '
<form action="', $scripturl, '?action=rate" method="post" name="topicRating" accept-charset="', $context['character_set'], '">
<div class="smalltext" style="width:25%; float:right; text-align:right;">';
if ( $context['topic_starter_id'] == $context['user']['id'] )
echo '
<span class="inline-rating">'.
$txt['cant_rate_article'].
'</span>';

else {
if ( $context['user_can_rate'] == 1 && $context['topic_starter_id'] != $context['user']['id'] )
echo '
', (!empty($modSettings['rateTopic_allow']) && !empty($context['user_rating'])) ? $txt['rate_article_again'] : $txt['rate_article'], '
<span class="inline-rating" style="padding-bottom: 3px;">
<ul class="star-rating">
<li class="current-rating" id="current-rating" style="width: '.($context['user_rating'] / 5 * 100).'%"></li>
<li><a href="javascript:RateThatTopic(1)" class="one-star"></a></li>
<li><a href="javascript:RateThatTopic(2)" class="two-stars"></a></li>
<li><a href="javascript:RateThatTopic(3)" class="three-stars"></a></li>
<li><a href="javascript:RateThatTopic(4)" class="four-stars"></a></li>
<li><a href="javascript:RateThatTopic(5)" class="five-stars"></a></li>
</ul>
</span>';

else
echo '
<span class="inline-rating">'.
$txt['rateTopic_please_wait'].
'</span>';
}

echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />
<input type="hidden" name="board" value="', $context['current_board'], '" />
<input type="hidden" name="rate" id="rate" value="" />
</div>
<script>
function RateThatTopic(value){
document.getElementById("rate").value = value;
document.topicRating.submit();
}
</script>
</form>';
}
echo '</span>
</h3>

</div>';


I have no idea if that was correct. Originally(in default template) it was supposed to be this:

Find:
<span id="top_subject">', $txt['topic'], ': ', $context['subject'], ' &nbsp;(', $txt['read'], ' ', $context['num_views'], ' ', $txt['times'], ')</span>

Replace with:
<span id="top_subject">', $txt['topic'], ': ', $context['subject'], ' &nbsp;(', $txt['read'], ' ', $context['num_views'], ' ', $txt['times'], '', (!empty($modSettings['rateTopic_allow']) && !empty($context['rating_average'])) ?  ' - '.$context['rating_number'].' votes)&nbsp;<span class="inline-rating"><ul class="star-rating"><li class="current-rating" style="width: '.($context['rating_average'] / 5 * 100).'%"></li></ul></span>' : ')' , '</span>';
//Topic Rating
if( !empty($modSettings['rateTopic_allow']) && !empty($context['rateTopic_board_enable']) && !$context['user']['is_guest'] ){
echo '
<form action="', $scripturl, '?action=rate" method="post" name="topicRating" accept-charset="', $context['character_set'], '">
<div class="smalltext" style=";width:25%;float:right;text-align:right;">';
if ( $context['topic_starter_id'] == $context['user']['id'] )
echo '
<span class="inline-rating">'.
$txt['rateTopic_topic_author_cant_rate'].
'</span>';
else {
if ( $context['user_can_rate'] == 1 && $context['topic_starter_id'] != $context['user']['id'] )
echo '
', (!empty($modSettings['rateTopic_allow']) && !empty($context['user_rating'])) ? $txt['rateTopic_Again'] : $txt['rateTopic_New'], '
<span class="inline-rating">
<ul class="star-rating">
<li class="current-rating" id="current-rating" style="width: '.($context['user_rating'] / 5 * 100).'%"></li>
<li><a href="javascript:RateThatTopic(1)" class="one-star"></a></li>
<li><a href="javascript:RateThatTopic(2)" class="two-stars"></a></li>
<li><a href="javascript:RateThatTopic(3)" class="three-stars"></a></li>
<li><a href="javascript:RateThatTopic(4)" class="four-stars"></a></li>
<li><a href="javascript:RateThatTopic(5)" class="five-stars"></a></li>
</ul>
</span>';
else
echo '
<span class="inline-rating">'.
$txt['rateTopic_please_wait'].
'</span>';
}
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />
<input type="hidden" name="board" value="', $context['current_board'], '" />
<input type="hidden" name="rate" id="rate" value="" />
</div>
<script>
function RateThatTopic(value){
document.getElementById("rate").value = value;
document.topicRating.submit();
}
</script>
</form>';
}
echo '


I reckon I screwed it up trying to modify it to fit my custom display.template code. Any ideas where it went wrong?

IchBin™

Quote from: Xarcell on August 23, 2010, 06:44:44 AM
Quote from: IchBin™ on August 22, 2010, 06:31:47 PM
It's most likely because you have put the style tags outside of the function Xarcell. Looks like it's not possible to add to the $context['html_headers'] inside the template though. I would either move it to the index.template.php file, or add it to the Display.php source file. I'm betting that is the cause of the errors that you're having. Trying removing all the code before the function and see if that fixes your problems.

I'm trying to understand what your saying, but I don't. I tried googling, but that didn't help either. Your not talking about the css, right?

If your talking about the quick modify form tags, they were already outside the function.

Can you give me an example of what a style is?

I'm talking about the code you have inserted at the very top of the file. Sorry I didn't explain better. You've put code outside the template functions, I'm not sure what that will do, just figured it could cause problems.

I don't know anything about that mod, but if you're having problems with it I'll have to take a moment to install the mod and see how it works and where it puts things.
IchBin™        TinyPortal

Xarcell

The code outside the template function shouldn't cause any problems, especially the css. While it's not proper, browsers will still read it.

I have installed it and looked at the code and how it works. Submit wil not work. Niether will the pol if I move it below the article, but above comments. If you haven't looked at it, you can see it in action HERE. be warned though, I make changes live, so it may be working one sec, and down another. Just wait a minute or so and it'll be back up.

Thanks for your help.

nend

Quote from: Xarcell on August 23, 2010, 07:46:03 PM
The code outside the template function shouldn't cause any problems, especially the css. While it's not proper, browsers will still read it.

I have installed it and looked at the code and how it works. Submit wil not work. Niether will the pol if I move it below the article, but above comments. If you haven't looked at it, you can see it in action HERE. be warned though, I make changes live, so it may be working one sec, and down another. Just wait a minute or so and it'll be back up.

Thanks for your help.

I don't see much of anything right now, I would like to see your idea at work. I have thought about doing what your doing in the past but I haven't thought of a appropriate layout.

KensonPlays

for me, i want the first post user's profile info to be on the top, rest on left side. how to do this?

Owner of Mesozoic Haven

nend

Quote from: Kcmartz on August 24, 2010, 02:16:53 AM
for me, i want the first post user's profile info to be on the top, rest on left side. how to do this?
The code has been worked out so forth. The basic concept is there for you to miss around with, just takes a little of CSS and HTML. I am more than sure you can handle it.

Xarcell

I just noticed that nothing is showing for guests. Give me time to track down why...

Xarcell

Oh man, I think it's because of this:       if ($context['topic_first_message'] == $message['id'])      to make first post different from replies. When I revert back to the original code it shows up. Any idea on how to fix this?

Xarcell

Quote from: nend on August 23, 2010, 10:28:05 PM
Quote from: Xarcell on August 23, 2010, 07:46:03 PM
The code outside the template function shouldn't cause any problems, especially the css. While it's not proper, browsers will still read it.

I have installed it and looked at the code and how it works. Submit wil not work. Niether will the pol if I move it below the article, but above comments. If you haven't looked at it, you can see it in action HERE. be warned though, I make changes live, so it may be working one sec, and down another. Just wait a minute or so and it'll be back up.

Thanks for your help.

I don't see much of anything right now, I would like to see your idea at work. I have thought about doing what your doing in the past but I haven't thought of a appropriate layout.

Here is a test account you can use to sign and see it. Right now it doesn't want to show for guest and I'm unsure as to why.

Username: Browser
Password: smf20rc3

MultiformeIngegno

RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Xarcell

Quote from: MultiformeIngegno on August 28, 2010, 09:50:18 AM
any news on this..?

Every works nicely, but I was unable to get anything to show up for guests.

IchBin™

It must be something else conflicting or something. I have put the change in my Display.template file. Whether I'm logged in as a guest or a user I see the same thing.
IchBin™        TinyPortal

Xarcell

Quote from: IchBin™ on August 30, 2010, 10:35:03 AM
It must be something else conflicting or something. I have put the change in my Display.template file. Whether I'm logged in as a guest or a user I see the same thing.

Weird, I tried every I knew to try, and guests could not see. I have hired someone to take a look at it, but I haven't heard back from them.

nend

Still nothing? Well if it doesn't work out just give me a PM and I can take a look for you. However I will not be available to look at it until Thursday. Sorry, just lack of time due to work.

NHWD

Quote from: Xarcell on August 20, 2010, 08:37:16 PM
For those wanting to know, this is what's being used so far:


      if ($context['topic_first_message'] == $message['id']) {

       echo 'template code';
}
       else {

       echo 'template code';
}

thanks for this.. i needed for something i was working on

Xarcell

Quote from: CL0WNER on April 17, 2011, 06:00:59 AM
Quote from: Xarcell on August 20, 2010, 08:37:16 PM
For those wanting to know, this is what's being used so far:


      if ($context['topic_first_message'] == $message['id']) {

       echo 'template code';
}
       else {

       echo 'template code';
}

thanks for this.. i needed for something i was working on


There is issues with that. I ended up having to hire someone...

NHWD

Quote from: Xarcell on April 17, 2011, 12:58:01 PM
Quote from: CL0WNER on April 17, 2011, 06:00:59 AM
Quote from: Xarcell on August 20, 2010, 08:37:16 PM
For those wanting to know, this is what's being used so far:


      if ($context['topic_first_message'] == $message['id']) {

       echo 'template code';
}
       else {

       echo 'template code';
}

thanks for this.. i needed for something i was working on


There is issues with that. I ended up having to hire someone...
what issues are they?

live627

The code won't execute as intended. $message['id'] isn't a boolean.

Advertisement: