Advertisement:

Author Topic: Smf user Menu Beta Mod  (Read 20967 times)

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Smf user Menu Beta Mod
« on: August 11, 2009, 07:02:08 AM »
arantor is probably best for answering this as he has helped me get the menu working

how would i include the menu (js) into the display.template.php OR the display.php file ?

i currently have the js set as an external function but im guessing im going to need to make it inline
« Last Edit: August 13, 2009, 06:18:19 PM by Faevilangel »
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #1 on: August 11, 2009, 07:07:20 AM »
If it's a big function, drop it into some of the JS that's floating about, generally by tacking it on the end of the JS normally loaded.

If it's not such a big function, inlining it is doable. If it's the script I think you're on about, it relies on an HTML fragment being in the document. Is that fragment being moved to wherever necessary on the page in order to work?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #2 on: August 11, 2009, 07:11:42 AM »
If it's a big function, drop it into some of the JS that's floating about, generally by tacking it on the end of the JS normally loaded.

If it's not such a big function, inlining it is doable. If it's the script I think you're on about, it relies on an HTML fragment being in the document. Is that fragment being moved to wherever necessary on the page in order to work?

yeah i will "remove" the link to the username and insert my own code, all the css will be added to the style.css

The thing is could the js be tacked onto the other js when the mod is installed ?

i know very little about the mod building process, but i know its done via an xml file that you tell the script to remove xx and replace with xxx
I am available for theme work, pm me for info

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,748
  • Master of BBC Abuse
Re: adding menu to the display.template / display.php
« Reply #3 on: August 11, 2009, 07:21:30 AM »
Just a warning, guys. For RC2 all the inline js is being moved out to separate files. ;)

I'd be inclined to call your own file, or add it to an external file that is already in SMF (at least if you're doing this for 2.0).

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #4 on: August 11, 2009, 07:22:46 AM »
Just a warning, guys. For RC2 all the inline js is being moved out to separate files. ;)

i have made this for 1.1 at the moment, but once i got that working then will see about moving it to rc2
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #5 on: August 11, 2009, 07:23:09 AM »
You can not only search/replace but add new content to the end of the file too. That reminds me, I am in the middle of writing a 'how to package a mod'.

The problem I see is that you have an HTML block that isn't being dynamically added - or is it? If it is being dynamically added, you could almost inline it.


Antechinus: thanks. We're discussing a possible mod, though, and I can see why you would encourage keeping inline scripts out of core even for mods.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #6 on: August 11, 2009, 07:28:20 AM »

The problem I see is that you have an HTML block that isn't being dynamically added - or is it? If it is being dynamically added, you could almost inline it.

in what way  ??? you have lost me  :P
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #7 on: August 11, 2009, 07:32:28 AM »
In your menu, you have a <DIV> and some <A> tags.

When it is being added? Are you added it in JS when the user clicks on the profile, or is it already there in the HTML, just waiting to be displayed?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #8 on: August 11, 2009, 07:36:24 AM »
In your menu, you have a <DIV> and some <A> tags.

When it is being added? Are you added it in JS when the user clicks on the profile, or is it already there in the HTML, just waiting to be displayed?

ah right, its already in the html, the js just changes the display attribute from  none to block
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #9 on: August 11, 2009, 07:39:15 AM »
Is it in the HTML once total, or once per user?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #10 on: August 11, 2009, 07:41:00 AM »
the menu can be hidden and shown any number of times, i have a working example at www.garethgillman.co.uk/menu.html
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #11 on: August 11, 2009, 07:41:55 AM »
You've missed my point.

Is it only a single instance of HTML on the page in total?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #12 on: August 11, 2009, 07:45:36 AM »
You've missed my point.

Is it only a single instance of HTML on the page in total?

yeah just once
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #13 on: August 11, 2009, 07:46:24 AM »
Are you repositioning the <DIV> in the Javascript then?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #14 on: August 11, 2009, 07:51:55 AM »
Are you repositioning the <DIV> in the Javascript then?

no its done with css, the js only shows / hides the menu
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #15 on: August 11, 2009, 08:03:12 AM »
How are you repositioning the menu then? Surely you have no control where the user will be on the page when they come to click this? (NB I'm assuming this is aiming for the thread display, where it will easily be more than a screen's height)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #16 on: August 11, 2009, 08:05:33 AM »
the div will be positioned right below the link, so when the link is clicked, it shows the menu right below the link
I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #17 on: August 11, 2009, 08:06:24 AM »
So if you only have 1 menu in the whole page, how are you positioning it?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #18 on: August 11, 2009, 08:28:44 AM »
So if you only have 1 menu in the whole page, how are you positioning it?
there isn't 1 menu, the html code is only inputted once, when the link to the poster is made, it *should* generate the menu bar below it too

it automatically grabs the users name, etc then shows the menu below the link when clicked

unless smf runs different to how i would want it implemented

I am available for theme work, pm me for info

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #19 on: August 11, 2009, 08:31:38 AM »
I think the fundamental question is where is the HTML being added to the page? (This isn't an SMF problem, this is an HTML problem)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.