News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Add a link back to website from SMF forum

Started by Chaoticone, September 05, 2016, 09:50:25 PM

Previous topic - Next topic

Chaoticone

I'm not sure if I should post here or not because this is an old topic: http://www.simplemachines.org/community/index.php?topic=476927.0 but it is so relative I hate not to.

riou, thanks for the link! Following it I got my menu edited and working like I want (without having to reverse engineer everything or have a phd in php) with one exception. The links do not open in a new tab but I wish they did. Anyone know if I can add a bit of code, use a different function, call or whatever it's called (I'm no programmer) to open the link in a new tab? I have used target="_blank" in some simple webpages before but php started throwing rotten fruit at me when I tried it this time.  :o Maybe a way to append the web address to include the target="_blank" in the end result?

SMF 2.0.11

This is the snippet I added.

// [External Links]
'exlinks' => array(
'title' => 'Some Other Websites',
'show' => true,
'sub_buttons' => array(
'view' => array(
'title' => 'Other Site One.net',
'href' => 'http://www.othersiteone.net/',
'show' => true,
),
'post' => array(
'title' => 'Other Site Two',
'href' => 'http://www.Othersitetwo.com/',
'show' => true,
'is_last' => true,
),
),
'is_last' => $context['right_to_left'],
),


Link to previous topic added for context - Iris.

Kindred

Add target as another variable in the array
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

skb

I have links to my website in 3 places on the forum. At the very top header, like this site, for which I used Custom Top Menu mod. The mod has an option for the links to open in a new tab. I have also linked my logo image to the website Home page, for which I added the 'target="_blank" to the <a href> tag in the index.template page. I have also used the Ultimate Menu mod to edit my Menu bar where I have added the website link to the Home button as a drop down option (also opens in a new tab) by adding target=_blank.   

SMF 2.1.4 / TP 2.2.2

Chaoticone

#4
Thanks guys! Works perfect now!  :)

So is each variable in the array basically just concatenated to a string in the end? Just guessing........ but that's slick enough for me either way. 

// [External Links]
'exlinks' => array(
'title' => 'Some Other Websites',
'show' => true,
'sub_buttons' => array(
'view' => array(
'title' => 'Other Site One.net',
'href' => 'http://www.othersiteone.net/',
'target' => '_blank',
                                                'show' => true,
),
'post' => array(
'title' => 'Other Site Two',
'href' => 'http://www.Othersitetwo.com/',
                                                'target' => '_blank',
'show' => true,
'is_last' => true,
),
),
'is_last' => $context['right_to_left'],
),

Sir Osis of Liver

Pretty much.  PHP puts it together and dumps an html string to the browser.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Deprecated

Not meaning to flog my own mod but it appears I already wrote what you wanted unless I misunderstood your request:

Custom Tab mod: http://custom.simplemachines.org/mods/index.php?mod=1402

Adds another button to your menu that you can name whatever you want and define a URL it takes you to. It could be a main site or a specific post (rules? forum staff?) or whatever you want.

You should never modify the code on your forum directly. Rather, you should use a mod package to do it. Write your own package if you want to modify your code. That makes it easy to do, un-do or migrate. It's a code maintenance issue. Mod packages allow you to track your code changes. Manual code changes require manual tracking.

Kindred

Quote from: Deprecated on September 06, 2016, 01:38:50 AM
You should never modify the code on your forum directly. Rather, you should use a mod package to do it. Write your own package if you want to modify your code. That makes it easy to do, un-do or migrate. It's a code maintenance issue. Mod packages allow you to track your code changes. Manual code changes require manual tracking.

well - while the statement is ultimately true, it does not take into account the fact that many folks don't know how to make a mod package or make on-the-fly updates....
So, if you don't want to make a mod out of changes and do want to make direct edits -- go right ahead. Just keep a log of exactly what you changed (and when/why) so that when you do the eventual large upgrade (either to reset your files to a clean set or to go to a version update like 2.1) then you can re-apply the same changes, if they are still needed.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Chaoticone

QuotePretty much.  PHP puts it together and dumps an html string to the browser.

Thanks Mr. Liver! BTW, you name, signature and avatar all in one place is jut too much........ killing me.  ;D

Quoteit appears I already wrote what you wanted unless I misunderstood your request:

Yup, you understood just fine. If your mod allows the creation of subs I will restore the backup I made and give it a go.

Kindred, I do make backups, a note of all mods (just a text file) and comment the code. But your right, I don't know how to make a mod (but think I have an idea how to). I will look at the docs more when I get time and see if I can figure it out. Also, thanks for the help. You have helped me more than once and always gave me solid input.  :)

I did notice something last night while testing the mod y'all helped me make . From my PC it works great. From my phone (note 5 in firefox) when you click on a button with subs you cannot select the subs. The calendar button has subs too so tested it and it has the same issue. Is this a known issue, have I hosed something up, just going at it the wrong way or.......? I think it makes sense why it doesn't work. No cursor on the phone so no "on hoover event" to expand the subs I'm guessing. Is there a fix for this?

Kindred

that actually depends on your theme....

responsive themes will allow a single touch to trigger the pull down menus. non-responsive themes probably will not...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Chaoticone

Thanks Kindred!

I try to stay as close to box stock defaults as possible so have never used any other themes (just copied and modified the default). I figure updates and maintenance for the life of the forum might go a lot better. But nowadays being mobile friendly is important. I will look at responsive themes tonight. Let me see what I see tonight. I need to research it before taking your time. I have not even looked at themes in years. I can probably view the list by ratings, stability or similar I would guess. If I have any questions after researching I'll ask then. But if you have any suggestions or recommend links ("tips to not paint yourself into a corner when choosing themes") in particular before making a decision, I'm all ears. 

Kindred


I installed Alpha Centauri and Studio003 by Bloc on three of my forums...  both needed some pretty serious tweaking to make them do what I wanted though.... (then again, almost any theme would, given that I had fairly specific ideas in mind for functionality and I was using the theme for a layout/look baseline.

That being said, there are some pretty good ones on the theme site.  Search for "responsive"
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Irisado

Quote from: Chaoticone on September 05, 2016, 09:50:25 PM
I'm not sure if I should post here or not because this is an old topic but it is so relative I hate not to.

For future reference, it is nearly always better to start a new topic, rather than to revive one which is four years old :).  Topic split on that basis.
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

Sir Osis of Liver

Quote from: Deprecated on September 06, 2016, 01:38:50 AM
You should never modify the code on your forum directly. Rather, you should use a mod package to do it.

Having spent many hours salvaging damaged forums that were trashed by crappy mod installs, and cleaning up databases with gb error logs from buggy mods, I can assure you a simple code edit is much safer than installing a mod to do something basic like the OP requested, provided the forum owner has the good sense to backup files before edits.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Chaoticone

Quote from: Kindred on September 06, 2016, 10:47:07 AM

I installed Alpha Centauri and Studio003 by Bloc on three of my forums...  both needed some pretty serious tweaking to make them do what I wanted though.... (then again, almost any theme would, given that I had fairly specific ideas in mind for functionality and I was using the theme for a layout/look baseline.

That being said, there are some pretty good ones on the theme site.  Search for "responsive"

Thanks Kindred! I will have a look at those. I did a search of themes for responsive and looked at a few. I'm not sure what I'll do. The only problem I have seen so far with the default themes are buttons with subs and my header image doesn't scale good but I think I fix that. I could add 2 buttons and been reading where some are doing what looks like a flex grid for the header area. If it comes down to it I could just use a smaller image for the logo too I suppose.

QuoteFor future reference, it is nearly always better to start a new topic, rather than to revive one which is four years old :).  Topic split on that basis.

Will do Irisado. Thanks for letting me down easy. If your avatar is a selfie I would imagine you have had lots of practice at that. Pretty lady!

Quote from: Sir Osis of Liver on September 06, 2016, 03:59:53 PM
Quote from: Deprecated on September 06, 2016, 01:38:50 AM
You should never modify the code on your forum directly. Rather, you should use a mod package to do it.

Having spent many hours salvaging damaged forums that were trashed by crappy mod installs, and cleaning up databases with gb error logs from buggy mods, I can assure you a simple code edit is much safer than installing a mod to do something basic like the OP requested, provided the forum owner has the good sense to backup files before edits.


Sir Osis.........  ;D Gets me every time. Had to tell the wife and kids about you. 

I could definitely find my changes easier than the ones a mod did for sure. But I must admit..... I did not do something right. It was spamming my error log.  :(

I made a note of it too though, gives "Undefined 8: Undefined index: href" error. Ill have to try to figure it out. I have taken it out and seems to have gotten rid of the errors. I will run Deprecated's mod or look at the files and see what it does different.

Quoteit appears I already wrote what you wanted unless I misunderstood your request:
Thanks Deprecated! Does this mod allow you to add buttons with sub buttons? Can I add multiple buttons with it? I have already downloaded it but will likely wait to install.

I do a good bit of scripting/coding. Enough that I created a custom language for notepad++ complete with an installer I built using nsis. I have some of the basics but this is a totally different world, different languages, etc. I'm sure I don't have to convince any of you (painfully obvious) but I'm not a programmer. Just self taught and stumble through it till I get it working good. I do a lot of that. Enough to know the value of backups for backups.  :laugh:

Deprecated

One button (with a name you pick) on the main menu then clickable links to as many pages as you have enabled, maximum 13. (Pages not enabled don't appear.) The links run across the top of the page you get when you click the main button and you pick what each link says, and fill in the contents with your text. Just think of it as a button that links to up to 13 pages you can flip back and forth between.

Chaoticone


Chaoticone

Gave it a go. Where do you enable and/or set the 13 pages? The only place I saw any configuration settings for custom tabs was in Config, mod settings, custom tabs. Can enable guest and members, set the label and do see the new button and if you enter a url it does go to that page. If you leave the url field blank, takes you to the home page of the forum. I don't see anywhere to set up or enable 13 links though. SMF 2.0.11

Deprecated

Quote from: Chaoticone on September 09, 2016, 10:12:29 PM
Gave it a go. Where do you enable and/or set the 13 pages? The only place I saw any configuration settings for custom tabs was in Config, mod settings, custom tabs. Can enable guest and members, set the label and do see the new button and if you enter a url it does go to that page. If you leave the url field blank, takes you to the home page of the forum. I don't see anywhere to set up or enable 13 links though. SMF 2.0.11

Please post your question in the modification support topic. I have already been criticized for off-topic posts in topics not related to my modifications:

http://www.simplemachines.org/community/index.php?topic=271527.0

Please read the full topic before posting. Your question may have already been answered.

Advertisement: