HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Footnotes Comcode?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#99653 (In Topic #19583)
Avatar

Community saint

Can comcode do this?

So I am curious, can a custom comcode be made (or does one exist) that does footnotes? If I do....

Code


Some stuff [fn]info on stuff[/fn] with penguins and pineapples


Can a comcode be made that would parse the stuff in the FN tags and send it to the "footer" of the post screen with a hotlink number that appears superscript next to the word that you are making a footer reference for?

I am just curious here and I would use the heck out of it. I am going to experiment with the idea, but if you know that might save me time/aggrivation.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#99654
Avatar

Community saint

Right now I got one like this…

Code

<sup><a href="#fn" id="r1">[1]</a></sup>
 <section>
     <p id="fn1"><a href="#r1">[1]</a>{content}</p>
    </section>

but the numbers don't advance and they don't go to footers. They do…

Footnotes test 2 [1]

[1]a second test


Will the numbers [1]

[1]a number is cool
advance?

So I am obviously missing something lol.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Item has a rating of 5 (Liked by mythus)  
Rating:
#99656
Avatar

It probably could be done in a pair of Custom Comcode tags, using some Tempcode, e.g. $INC to set a number, $SET to set something into a variable. However it'd be pretty hard.

I've put it on the tracker in case anyone ever wants to sponsor it:
0001353: Footnote Comcode tag - ocPortal feature tracker

It would be a cool little feature.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#99657
Avatar

Community saint

Yeah, it definetly looks like it. The challenge seems to be the increasing number and forcing the reference to the bottom.

It would be a nice feature. If I had a better grasp on code, I'd be working on this. That and time.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#99658
Avatar

Community saint

The trick I think is to build the final html at the time the [fn] tag is used and store it in a string as you go along.

The in the second comcode tag you just print the contents of the string where you want the footer to go.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#99659
Avatar

Community saint

Well here,s what I got incase it is helpful, but it is not much…. and not very elegant.

I did 2 tags.

The FN tag

Code

<sup><a href="#fn" id="r$INC">[]</a></sup>

The Reference tag

Code

<section>
     <p id="fn"><a href="#r$INC">[]</a>{content}</p>
    </section>

Using it looks like this

Code

A test of stuff [fn=1]1[/fn]
Because we love to test [fn=2]2[/fn]


[fnr=1]this is a test[/fnr]
[fnr=2]fun stuff[/fnr]

Which gives this (sort of lol)
A test of stuff []
Because we love to test []


[]this is a test

[]fun stuff

But yeah. I can't get the number in [] to increase, and anything put in [] comes out as is. Maybe it is how [] does things?

Trying to give back from yesterday = not so good. But yeah.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Item has a rating of 5 (Liked by mythus)  
Rating:
#99660
Avatar

Community saint

The FN should be something like this:

Code

{$INIT,counter,0}
{$INIT,sec,}
{$INC,counter}

<sup><a href="#fn" id="r{$GET,counter}">[]</a></sup>

{$SET,sec,{$GET,sec}<section><p id='fn'><a href='#r{$GET,counter}'>[]</a>{content}</p></section>}

{$GET,counter}

A counter is initialised and incremented, the sub is displayed and the section is built/appended-to and stored in the sec variable for later use.

The reference tag is just a simple dump:

Code

{$GET,sec}
.

That's the rough idea anyway.

That all I've got for now, I'm off to bed.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#99661
Avatar

Community saint

That makes sense and is close. As always temp, you are awesome!

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#99662
Avatar

Community saint

OK, I used temp's code, with a small change…

Code

{$INIT,counter,0}
{$INIT,sec,}
{$INC,counter}

<sup><a href="#fn" id="r{$GET,counter}">[{$GET,counter}]</a></sup>

{$SET,sec,{$GET,sec}<section><p id='fn'><a href='#r{$GET,counter}'>[{$GET,sec}]</a>{content}</p></section>}

{$GET,counter}


That gives us the increased numbers in the brackets, but repeats them out of bracket. You also have to use a fnr tag at the bottom of the post, though this could be negated by adding the get sec to the right template. I'll investigate that.

In te mean time, results.
A test of stuff [1] 1
Because we love to test [2] 2

[]we love to test

[

[]we love to test
]fun stuff

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#99663
Avatar

Community saint

OK, I made more progress.

FN

Code

{$INIT,counter,0}
{$INIT,sec,}
{$INC,counter}

<sup><a href="#fn" id="r{$GET,counter}">[{$GET,counter}]</a></sup>

{$SET,sec,{$GET,sec}<section><p id='fn'><a href='#r{$GET,counter}'>[{$GET,counter}]</a>{content}</p></section>}
FNR

Code

{$GET,sec}




Still have to use both comcodes as I dont know which template to edit.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#99683
Avatar

Community saint

mythus said

Still have to use both comcodes as I dont know which template to edit.
Where do you want to place the FNR? Et the end of the post or at the bottom of the page?

Keep in mind that comcode variables scope is the life of the page, so if you have multiple post on the one page then the numbers will not repeat between posts, so the the bottom of the page is the only logical place.

If you want each post to have its own FNR then that complicates matters. I didn't think you were going to use it in forum posts, which you appear to be.


Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#99684
Avatar

Community saint

Wooops, forgot to add a little correction to FN:

Code

{$INIT,counter,0}
{$INIT,sec,}
{$INC,counter}

<sup><a href="#fn{$GET,counter}" id="r{$GET,counter}">[{$GET,counter}]</a></sup>

{$SET,sec,{$GET,sec}<section><p id='fn{$GET,counter}'><a href='#r{$GET,counter}'>[{$GET,counter}]</a>{content}</p></section>}
It just gives unique references to the FN's so that the links work properly.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Item has a rating of 5 (Liked by mythus)  
Rating:
#99688
Avatar

Community saint

OK, I've had a bit of a chance to actually play with the code and discovered a few tweaks that need to be made.

For FN, I now have:

Code

{$INIT,fn_counter,0}
{$INIT,fn_uid,0}
{$INIT,fn_sec,}
{$INC,fn_counter}
{$INC,fn_uid}

<sup><a href="#fn{$GET,fn_uid}" id="r{$GET,fn_uid}">[{$GET,fn_counter}]</a></sup>

{$SET,fn_sec,{$GET,fn_sec}<section><p id='fn{$GET,fn_uid}'><a href='#r{$GET,fn_uid}'>[{$GET,fn_counter}]</a>{content}</p></section>}
All variables and id's now have an fn_ prefix to reduce the risk of conflict with any other comcode tags or object id's that may exist now or in the future.

The uid variable is used to ensure link id's are unique on the page, regardless of how many posts may have FN's.

For FNR, its now:

Code

{+START,IF,{$NEQ,{$GET,fn_sec},}}
{$GET,fn_sec}
{$SET,fn_sec,}
{$SET,fn_counter,0}
{+END}

It now resets the footnote numbers so that they start at 1 in each post, while not resetting the link id's so that the links jump to the right place.

While the {+START}…{+END} is technically not needed as-is, its there in case you need to add formatting, like a line break, around the FNR.


Last edit: by temp1024

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#99690
Avatar

Community saint

As always temp' you are awesome.

It would be ideal so that this comcode could be used anywhere. If it is used in a post, the reference (FNR) is given at the bottom, or footer, of said post. If it is used in a CEDI or COMCODE page, then the FNR goes at the bottom of or footer of that article/page.

I'd use it in forum posts largely to provide OOC description/definition of the unique terms and things found in Nor'Ova without breaking the flow of the story. Others might use it for other referencing needs in a post. But admittedly the largest use would come from CEDI(Wiki+), article, and comcode pages.

Could you even imagine the added complication if someone wanted to use it in say catalogue fields? Sure, such a use case would be extremely rare and unlikely, but being comcode, it is possible to use it in any area that comcode can be used.

So as awesome as having the FNR automagically appear in the "footer" of the area you are using it, maybe it would be best to use it by the FNR tag? It would be the simplest codewise. And then the poster or author could apply the reference where needed.

Hey Chris, looks like temp's pretty much got the comcode made.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Item has a rating of 5 (Liked by mythus)  
Rating:
#99691
Avatar

Hey Chris, looks like temp's pretty much got the comcode made.

Yes, I'm very impressed by you guys :).

If we were going to add this officially, we'd not use Tempcode, just because we could do a simpler and slightly faster (static) solution in PHP, but that's beside the point really. The tracker issue links to this topic, so people will find the solution.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#99693
Avatar

Community saint

99.9995% of this is all temp lol.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Item has a rating of 5 (Liked by mythus)  
Rating:
#99703
Avatar

Community saint

The way its written it should be able to be used just about anywhere, including catalogues, as-is, subject to any styling changes you want to make of course.

Give that you actually want to use it everywhere its best to put the FNR in templates and not rely on people remembering to manually add FNR to their posts/articles.

You can find the appropriate templates easy enough using the admin page rendering tools.

In forum posts, for example, you can edit  OCF_TOPIC_POST.tpl and maybe place the [FNR][/FNR] just before the {LAST_EDITED}.

In any other template you should find any place before a comments section.

For catalogues, you will also need to consider if you want FNR to appear after each catalogue entry or after all catalogue entries for the given page, and place the FNR accordingly.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#102553
Avatar

Community saint

I know, Necrobump… but…

It sucks getting older because I can't for the life of me remember how I got this to work before…. and that sucks because I liked this code….

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
Posted
Rating:
#102555
Avatar

Honoured member

mythus said

Yeah, it definetly looks like it. The challenge seems to be the increasing number and forcing the reference to the bottom.

It would be a nice feature. If I had a better grasp on code, I'd be working on this. That and time.

Now Time that's the thing i'm always short of

Just Jarv
Back to the top
 
Posted
Rating:
#102556
Avatar

Community saint

LOL I hear you.

I wish I could remember everything on how I got this to work before. I thought it was all documented here, but I guess I am missing something.

I can live without it, but it sucks to not get something working that I once had working before. Makes me feel like I'm getting much older than I think I really am.

Legends of Nor'Ova: A site powered by ocPortal; home of the Legends of Nor'Ova tabletop RPG wiki and community.

Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!

"Those who want help should first be willing to give help."
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: