Attention:

Support Rules and Guidelines
Before you post your support topic, please remember to:
  • Read the support forum rules.
  • Check the wiki and use search to see if your problem can be answered there first.
  • Link your board please, and make sure that the problem on your board is visible to guests or provide a test account.
  • Do not post Board Wrappers and CSS unless requested. With a board link, this is not necessary.
  • Be as descriptive as you can and use as many details as possible when describing your problem.
  • Please briefly mark any links to forums that may not be work-safe.
This will help ensure your support issue will be attended to in a quick and efficient manner.

  Add ReplyNew TopicNew Poll

 Targeting only the first post in a topic
#
Is that possible? I want to style my thread template so that the first post in ever thread looks different, and I've been trying to figure out how but I just can't seem to work it out. Has anyone else cracked this one yet?

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
How big of a change are you looking for? The nth-of-type should work handily if it's just minor style changes, but if it's a full template that'd be a little more involved.
PM
#
The problem I'm running into with nth-of-type is that it would be the first post on every page, rather than just the first post, if that makes sense? What it boils down to is I'm trying to show a div that's currently hidden, but only for the very first post on the thread.

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
Oh, right, I forgot how pages work for a minute :b Without busting into Javascript, the only way I can imagine this being done would only work for topics with 2 or fewer pages (which would be kinda limiting). It'd be interesting to have a page number variable, but in the interim if you don't mind JS, something like this would work:
CODE
document.getElementsByClassName('post-normal')[0].className += ' onPage' + document.getElementsByClassName('pagination_current')[0].children[0].innerHTML
PM
#
Dusty I hate to bother you with this, and if you're not feeling up to it please do ignore this tag! Unfortunately I am nearly Javascript illiterate, and while I've tried to make sense of this I'm getting nowhere.

Here's exactly what I'm trying to do, in case it helps. My post template looks like this, simplified:

<div class="post-template"> post here </div>
<div class="hidden-element"> content here, set to display: hidden via CSS </div>

What I'm looking to do is put something in the board guidelines of certain forums on my site which will show .hidden-element - if that makes any sense? Let me know if I can give you more info and, again, if you're not feeling up to tackling this then please do ignore it!

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
It's totally fine! I'm not entirely sure I know what you're going for, so just to clarify: You want something in the forum guidelines that will, on the first page only (and for the first post only?), make .hidden-element visible?
PM
#
Exactly! The code would be in the 'Support Rules and Guidelines' section that's on this page, for example. The reason being that I only want this information available on the first page and only in certain forums.

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
Super sorry for the delay!

Unless I'm mistaken, though, you can just use the script from earlier:
CODE
document.getElementsByClassName('post-template')[0].className += ' onPage' + document.getElementsByClassName('pagination_current')[0].innerText


And then affect the CSS change using .onPage1 + .hidden-element to set the display property.

The script will only work properly if there's more than one page to the thread (which is handy), though, so fair warning. You can also stick that script inside a function to be executed inside the forum guidelines, if you're looking to minimize the content inside the forum guidelines.

CODE
<script>function _postNum() {document.getElementsByClassName('post-normal')[0].className += ' onPage' + document.getElementsByClassName('pagination_current')[0].innerText}</script>


in the forum wrapper, and called as

CODE
<script>_postNum()</script>


in the guidelines area
PM
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Share this topic:
« Next Oldest | General Support | Next Newest »

Options Add ReplyNew TopicNew Poll