Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Robert222 Posted January 8, 2021 Posted January 8, 2021 I used to run a website powered by Shopify and I placed one piece of Google Ad code within my "Shopify" global template. This automatically enabled google ads to appear across my website. From within my Google Adsense account I was then able to control where ads were placed across my site and easily select which parts of my website pages should not contain adverts. This was the handy part of working with Shopify. Anyway, I've moved on to IPS software and manually setup google ads on all pages etc for example... within my side bar and top / bottom sections of all pages using "Blocks", which so far seems to work okay. However the main part of my website involves uploading article content and if the article is long and users are scrolling down the page when reading an article, the side bar ads begin to disappear because they are further up the side bar page. Does that make sense? So users begin to see nothing within the side bar as they continue to read the article. And this means the opportunity for generating revenue from google adsense becomes non-existent, until the user finally reads down to the bottom of the article and then they see a google advert (footer Block ad). So in regards to my own website, I don't wish to place that one piece of Google Adsense code within my IPS Global Template because then adverts will appear in all pages and IPS has a greater number of pages compared to Shopify. So the plan is I wish to place the code within only my Articles section so that google Adsense Ads will appear throughout only my posted articles but I have no clue as to where to place the 'In-Line Google Adsense Code'? Which template controls the article contents? I have no idea and require help. IPS support can't even guide me in the right direction!
Nathan Explosion Posted January 8, 2021 Posted January 8, 2021 2 hours ago, Robert222 said: So users begin to see nothing within the side bar as they continue to read the article. So maybe make the sidebar sticky so that it is always in view? Edit core -> front -> global -> sidebar, and add data-ipssticky to the opening div: <div id='ipsLayout_sidebar' class='ipsLayout_sidebar{$position} {{if !( isset( \IPS\Output::i()->sidebar['contextual'] ) && trim( \IPS\Output::i()->sidebar['contextual'] ) !== '' ) && ( !isset( \IPS\Output::i()->sidebar['widgets']['sidebar'] ) || !\count( \IPS\Output::i()->sidebar['widgets']['sidebar'] ) ) && \IPS\Dispatcher::i()->application->canManageWidgets() && !$adsForceSidebar}}ipsLayout_sidebarUnused{{endif}}' data-controller='core.front.widgets.sidebar' data-ipssticky>
Robert222 Posted January 8, 2021 Author Posted January 8, 2021 Just tried what you suggested and as soon as I began scrolling, the side bar popped out the page and moved to the left hand side of the screen. Did not look correct at all.
xtech Posted January 8, 2021 Posted January 8, 2021 Adsense doens't like ads on sticky divs. I've tried some years ago and the ads simply did not appear. Google doesn't like any "tricks" to draw attention to the ads - although imho making them sticky is not properly a "trick".
bfarber Posted January 11, 2021 Posted January 11, 2021 When you add a sidebar widget, it only displays on those pages. So you can create a custom HTML block (using Pages) with your Google adsense code, then add that block to all of the pages used by Articles (i.e. the index, category listing, article listing and article display pages). The block won't be shown suite-wide, but will be shown on all pages you add the widget to.
Robert222 Posted January 11, 2021 Author Posted January 11, 2021 8 hours ago, bfarber said: When you add a sidebar widget, it only displays on those pages. So you can create a custom HTML block (using Pages) with your Google adsense code, then add that block to all of the pages used by Articles (i.e. the index, category listing, article listing and article display pages). The block won't be shown suite-wide, but will be shown on all pages you add the widget to. I still don't understand. I already have google adsense blocks positioned at the top and bottom of all pages of my site, including the side bar. The next thing I'd like to do is include google adsense blocks within the content of all my website articles. Below is an example of an article on my site. I'd like to show google ads between paragraphs. Google adsense provides In-Line Ad Code which just needs to be added to a page template. So would I be right in saying if I create another google adsense block containing In-Line Google Ad code and add it to the "Index", this would enable google adverts to appear throughout the below article?
bfarber Posted January 12, 2021 Posted January 12, 2021 If you want to add ad code inline in an article, you will need to edit the appropriate template to display it. This will be in the Pages template area, with the specific template you needing to edit depending upon your database configuration. It will be the record view template specifically you'll want to edit.
xtech Posted January 12, 2021 Posted January 12, 2021 (edited) You would need more advanced processing inside the template. Remember: article content is in field $record->_content. This field is a String that contains the HTML code that by its turn, contain your article text, images, etc. As an example, if you want to set an ad after the first paragraph and before the second paragraph, then you need to edit the record display template as follows: find the first paragraph end tag (</p>). You can do it with string functions or regex. Split the the string at that position (so you will have one string with the first paragraph, (let's call it $content1), and one with the remaining content ($content2). Create a new string $adsensecode and set it as: "<p>with_your_adsense_code_</p>" Conconcatenate $content1 . $adsensecode . $content2 Instead of using $record->_content to display article content, use $yourconcatenatedcontent Enjoy. Edited January 12, 2021 by xtech Sonya* 1
Robert222 Posted January 12, 2021 Author Posted January 12, 2021 2 hours ago, xtech said: You would need more advanced processing inside the template. Remember: article content is in field $record->_content. This field is a String that contains the HTML code that by its turn, contain your article text, images, etc. As an example, if you want to set an ad after the first paragraph and before the second paragraph, then you need to edit the record display template as follows: find the first paragraph end tag (</p>). You can do it with string functions or regex. Split the the string at that position (so you will have one string with the first paragraph, (let's call it $content1), and one with the remaining content ($content2). Create a new string $adsensecode and set it as: "<p>with_your_adsense_code_</p>" Conconcatenate $content1 . $adsensecode . $content2 Instead of using $record->_content to display article content, use $yourconcatenatedcontent Enjoy. Not great for us non-coders! But I do appreciate the help.
xtech Posted January 12, 2021 Posted January 12, 2021 2 hours ago, Robert222 said: Not great for us non-coders! But I do appreciate the help. Sorry 😞 there is no "non coder" way to do what you want, unless someone does a plugin for this.
Recommended Posts