1 (edited by intedinmamma 2007-09-15 19:10)

Topic: More markup (classes, ID's)

It would be great to have more markup to mess around with, both for CSS and JS. An example: A forum I'm working on, eldvakt.se, uses jQuery to get the three newest topics from each forum and display them below each forum. To be able to do this I had to edit index.php and add the forum ID ('f'.$cur_forum['fid'] to be exact) as an id and the class "forum" for each row. The JS is unobtrusive, and gets the data from a modified external.php.

It would've been great if this had been there by default, and also things like topic id, post id, user id and whatever. smile It's not a lot of work, poses no security risk and won't impact bandwidth, well, not much. It becomes a lot easier to do things like inline editing and other "AJAXy" stuff with it, wich we all like. wink

Edit: Ouh, and an easy way to add JS would be nice, but I assume that's coming in 1.3.

Re: More markup (classes, ID's)

I second this.

Not for the same reason, but having at least an ID by forum (and forum's category) would allow hyperlink to it (with an anchor).

3

Re: More markup (classes, ID's)

This is one of those where I agree and disagree. Having an id for each forum makes sense and is already there in 1.3. However, I don't quite see the point of the class as surely javascript can locate an <tr> without it having a class. It also doesn't help from a css point of view as you can just style the <tr> via a descendant selector.

More classes and id's whilst not harmful is not as simple as it sounds for the basic reason that the placement of id's and classes will rather depend on what you want to use them for. For example, lets say you have a board dedicated to discussing football. You decide you want each forum to reflect team colour. Easy enough to style the index page via a different id on each row. But what happens when you get to viewforum. Do you want the id on the main table which makes semantic sense or do you want it on the page wrapper so the whole page can be styled in the teams colours. And what happens when you get to viewtopic, should it have the forum id, the topic id or both and where do you put them?

Re: More markup (classes, ID's)

Well, the class is just because I'm lazy (and didn't think it through) when I did the page mentioned above. roll I "need" the ID of the element you're clicking/doubleclicking/hovering when things like inline editing and such are, well, there. User ID (and a class like "userlink") on links to user profiles, topic ID (.topiclink) on links to topics, and so on. The problem with the football teams is not really hard to solve, just add the forum name/ID as a class. That makes even more sense. (IMHO) Adding user ID (or group ID) as a class to a post also makes it possible to make the administrators/moderators posts "stick out" from the rest, as they hopefully have something important to say. wink (endless are the possibilities!)

But yes, it depends a lot on what you want to use it for. And I need to stop babbling. roll

5

Re: More markup (classes, ID's)

You are not babbling. I've been thinking about this stuff for months. The problem is its not going to be possible to cover every possible situation therefore I have to come up with something which is flexible enough to please most of the people most of the time. In the end all of this is actually an argument in favour of templates which of course can be coded for a specific purpose.

I did think about group id's on posts as well as various other things but ended up with seven classes on the same div. Thats another problem. There are tons of useful things that can be done but you have to know when to stop. Again it comes down to what is going to be most useful to most people.

I always want to hear what difficutlies people are having though because my idea of what users might want to do is purely my own opinion and it might not accurately reflect what people really want or need.

One addition that would certainly be useful is either class="external" or rel="external" on links which would allow for javascript to open a new window for external links.

Re: More markup (classes, ID's)

Templates does indeed solve this problem. smile Btw, are the template files then going to be .php-files instead of .tpl?

Re: More markup (classes, ID's)

Just to be clear, he said it's an argument in favor of templates, not that 1.3 will necessarily have templates (meaning "real" templates, not the tpl files we have now). wink

Re: More markup (classes, ID's)

Paul wrote:

More classes and id's whilst not harmful is not as simple as it sounds for the basic reason that the placement of id's and classes will rather depend on what you want to use them for. For example, lets say you have a board dedicated to discussing football. You decide you want each forum to reflect team colour. Easy enough to style the index page via a different id on each row. But what happens when you get to viewforum. Do you want the id on the main table which makes semantic sense or do you want it on the page wrapper so the whole page can be styled in the teams colours. And what happens when you get to viewtopic, should it have the forum id, the topic id or both and where do you put them?

This how I would do it:

On the index view (forums listing), the real (higher on the tree) container (whatever it is) of each forum has the ID of that forum. That also includes categories. It cover your example, and allow direct hyperlinking to it.

On the forum's view (threads listing), thread and post view, I would apply the forum's ID to the body of the page, and the categories's ID as classes for the body of the page.

As for syntax, it might be something as simple as f21 (for forum #21) and c3 (for category 3).

9

Re: More markup (classes, ID's)

You can't use the body tag. PunBB is a site component so it might have to fit into an existing page which already has an id.

You can't use the outer wrapper because that already has an id which is the page identifier. It also has the class .pun which is used for sandboxing. That means adding extra wrapping divs.

Re: More markup (classes, ID's)

Yeah, it seems like the only way around that would be to add another wrapping div right after the .pun div.

11 (edited by Jérémie 2007-09-17 02:11)

Re: More markup (classes, ID's)

Paul wrote:

You can't use the body tag. PunBB is a site component so it might have to fit into an existing page which already has an id.

Good point.

You can't use the outer wrapper because that already has an id which is the page identifier. It also has the class .pun which is used for sandboxing. That means adding extra wrapping divs.

Add it as a class then. Semantically, it's quite the same for this issue.

But I would also add it to the body, because if one's PunBB install is a standalone, one might want to be able to select the highest selector possible (and if it's integrated, then he doesn't need it).