Insert script in index page

Philip Lozier Posted in Technical Support 3 years ago

Okay. I'm going to "try" and not be frustrated that everything has to be a NIGHTMARE to implement with this because it just can't be done in the "normal" way... anyway:

I am trying to work with a few different advertising providers. A couple of them REQUIRE code to be put in between the <head> and </head> portion of the index page... NO PLACE ELSE, separate from the ad code itself, in order to work. So... we can't edit the "core" files that would take care of that, which would be the NORMAL way to do it, but we can't do it. RUBBISH. So the problem is now there.

In the NORMAL world I should just have to cut and paste the code in between the <head> and </head>, 30 seconds, and DONE. Simple... but... NOPE. Not here.

Before the suggestion of Homelancer Custom CSS/JS ... been there, done that, NOT WORKING. WHY in GOD's name would it want the <script> and </script> tags (THE NORMAL WAY) not included with the code provided by the companies that companies that provided the code, so it would work the way THEY intended it to, instead of somebody thinking their component might know how to put it in better?????? RIDICULOUS! WHY is EVERYTHING done with OSSN not done the NORMAL way???

IS there ANY way for me to implement these codes as the code providers intend it to be without having to repeat the process of updating core files every time there is an OSSN update? I'm not trying to spend multi thousands of dollars a year running my site and not generate multiple ad source revenue. How can I fix this?

us Philip Lozier Replied 3 years ago

Yea... re-reading your comment... that "instead" part is the killer. That makes it one or the other. Not even close to a good solution... again... exactly why I suggested a separate component. What good, and in what way is it productive, to add one useful function at the expense of losing another equally as useful function? The ad component should support BOTH, or a separate component is actually -needed- if it's not possible to iclude both. Like I also said earlier, I am surprised (it's a no brainer) it doesn't already exist. It's a no brainer, at least for somebody who isn't just running a site for a hobby. I'm starting to have trouble making friends with some of the logic in the development approaches. It's 2021... running a social site that 2010 is screaming to have given back to it is becoming a little less than... tolerable. I wish I didn't have so much work into it and a growing userbase and could start from scratch.

us Philip Lozier Replied 3 years ago

Sorry for the delayed response, was out of town for a week doing contract work. Anyway... your idea went through my mind. Didn't know how willing the developers would be to change the existing ad component that way. To be able to optionally ad snippets for ads would be fantastic, BUT, the original functionality of adding a page link with a display image would also have to remain in place as the are key putting up direct link affiliate advertising, or private ad accounts between the webmaster and client. If the developers would be willing to add the option and keep the original functionality in place as well, that would be superb. that is the only reason I suggested a separate component. BTW, the link you provided in your response produces a 404 for me.

German Michael Zülsdorff Replied 3 years ago

I looked into things a bit ... and ...

I can't make friends with having another ad component in parallel. My idea would be enhancing the existing OssnAds to allow entering 3rd party code snippets instead. I have tried that with the code I found at, and indeed got that

enter image description here

The problem: Most often you can't blindly copy/paste such code. Same here. Hence, if you have no understanding of which part to enter it's likely to provoke a script error and your entire site stops working in the worst case.

Not long ago you wondered about the influence of the MentionsUI component on the delete function - but in fact the script interpreter does not react very much differently than reality when it comes to dependencies:

Let's say, you are on your way to a supermarket to buy a case of beer and the road is unexpectedly closed due to flooding: It's not that there would be no more beer in place - you just can't reach it anymore. 🤔

To put it this way, surprises are always guaranteed when using 3rd party scripts, and up to now I don't see no real foolproof way of how and where to add them.

us Philip Lozier Replied 3 years ago

Well... now I HAVE enabled it as a temporary measure just to hope to drive some revenue, but like I thought... it is too much for the top of the mobile view.

us Philip Lozier Replied 3 years ago

I am absolutely certain I have NOT enabled that, as that is not the desired behavior I was describing, AT ALL. Not even close. The behavior I was describing is for it to appear in between post in the similar fashion of ads inserter. On top of the posts in mobile view is too much junk already with announcements and contact suggestions.... too much stuff and users don't like it and go elsewhere. In between posts is less obstructive to the flow of the system. Also, it would be a nightmare if there were multiple ads in html sidebar, as no way to separate them for random, individual, display.

To explain again...

A component that behaves like the current ads component.

A back end that allows INDIVIDUAL code to be entered, seperately, as seperate items, individualy, like the photos and links in the regular ad component.

Has a behavior like the regular ad component ad inserter to place randomly one of the individual items between posts at intervals.

This is something that probably every single webmaster that runs OSSN with ads would use. I'm surprised it soesn't already exist... I think I may have even saw an older post way back in there somewhere where others were looking for something similar to this. Would probably be one of the most popular components.

For it to not be a replacement for the current ad inserter, but to be another seperate one that can be run at the same time.

German Michael Zülsdorff Replied 3 years ago

Works good. Using html sidebar for experimenting with others. Works good except for mobile... don't see it.

And you're sure you have enabled this option?

enter image description here

us Philip Lozier Replied 3 years ago

@~Z~ Man ... LOL! No... You misunderstood that part. I was talking when I was saying about not being ridiculous about a component like Arsalan described being something with a back end that could be a paid component, and an ad component similar to the current ad component, but able to put code for 300x250 standard (among a lot of ad providers) , or maybe others as well, in the display. Same type of back end as current ad component, but you put code. Instead of displaying all ads in right sidebar it displays one, and also has built in ad inserter like one available for current ad component. Keep the 2 ad components separate so you can use both. That covers most need for ads throughout the system. For my extra custom pages I am already using the custom page component, which is easy to put the code in. Have sliders coming up off the bottom right of the pages.

it would make a good PAID component, as webmasters are using it to make money. I'm sure it would be popular. Current one good for direct link ads for people who pay direct to webmaster, or affiliate links, the one I suggest for things like AdSense, ylliX,, Propellor, etc. I am using current ad component for a few things. Works good. Using html sidebar for experimenting with others. Works good except for mobile... don't see it. I'm sure people would pay for what I suggest to make it easier to impoliment <head> scripts> and handle in pages what HTML sidebar lacks.

German Michael Zülsdorff Replied 3 years ago

No, these ideas aren't rediculous, but very complicate to implement.
Because there's no static <body> ... </body> structure in Ossn, but the inner contents gets 'rendered' dynamically on load. And since any script that wants to display something somewhere does need an anchor to know where, it still needs an intimate knowledge of the framework and manual inserting of that anchor in the right place. It definitely can't be accomplished by just adding all that to just one file.

us Philip Lozier Replied 3 years ago

@Arsalan Shah ... I fully understand. Doing art for money is why I haven't done any art in years. Once I started being obligated for projects, it took the fun out of it, so I understand. The separate file for the custom changes would be a godsend though. Than I would take the time to redo everything on the virtual machine I have set up knowing I would only have to do it once. Right now, with the high amount of compliments I have been getting on the appearance, and even being told it surpasses my competition, I'm not looking to disturb things.

Thanks for everything you do.

us Philip Lozier Replied 3 years ago

@Arsalan Shah ... Thank you for the code you provided below, and although I have already applied it in theme.php I am going to try it via this method. Although I am -not- a developer I -am- trying to learn as much as I can. No... I didn't mean to add thousands of scripts... but a component for OSSN , similar to the homelancer custom js/css, (but just for the scripts) that allows individual script entries, as provided by the provider of the script without stripping anything, would be a very, very, useful thing. Even as a paid component, as I believe this would be primarily used for advertising scripts that webmasters will make money off of. I mean, doesn't it make sense? The question has been asked before about advertising scripts in other messages... but the answer has only ever been given about for in between <body> and </body>.

Also... to accompany this, (also as a paid component), a second ad component. One that takes code so box display ads can be put in it... built in ad inserter like the current one so mobile users see it as well. Only difference is that in the sidebar it only displays one ad. This, separate from the current one as current image ad with direct link is good for affilitae advertising. It would make for a very useful, and I am sure very popular, PAID component. BOTH the code one, and the display one.

If I knew how to code, I would have done both weeks ago. I don't think these ideas are ridiculous, or overboard... and I think they would add to the attractiveness of OSSN as a platform for those looking for more a commercial venture.