Off-TopicExtending Advertisement Template Locations

All the various Off-Topic crap here ;)
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Mac OS X Firefox

Extending Advertisement Template Locations

Post by Exabot »

Hello

Can anyone help me with this?
I only need banners to appear on the front page (index_body.html), but I can't get it to work… :sad:

Extension is Advertisement Management.

The Advertisement Management extension allows you, extension developers, to add new template locations for advertisements to display. To do this in your extensions, follow these simple instructions:

1. In your config/services.yml, add new location declaration like this:

Code: Select all

demo.extension.location.type.location_name:
        class: demo\extension\location\type\location_name
        arguments:
            - '@user'
            - '@language'
        tags:
            - { name: phpbb.ads.location.type }
  • Always prefix the location type with your vendor and extension name.
  • Tag is crucial here and must be named phpbb.ads.location.type

2. Add a location type class in location/type/ directory, for example location_name.php.
  • It must implement \phpbb\ads\location\type\type_interface.
  • We strongly encourage you to extend \phpbb\ads\location\type\base.

3. Implement required methods.
  • See \phpbb\ads\location\type\type_interface for their descriptions.
  • Regarding get_id(), we strongly suggest using your vendor and extension name as a prefix, i.e.:

Code: Select all

public function get_id()
        {
        	return 'demo_extension_location_name';
        }
  • Please note, that when you inherit from \phpbb\ads\location\type\base, you don’t need to bother with get_name() and get_desc() methods when you use proper language keys as such (where <location id> is a capitalized form of get_id()):

  • AD_<location id> for location name
  • AD_<location id>_EXPLAIN for location description


4. Implement optional method will_display(). If your location is not present on every page, we strongly encourage you to implement this method.
  • You can use $this->user->page['page_name'], $this->user->page['query_string'] or any other techniques to decide whether your location should display on a given page.
  • Don’t perform resource-expensive calculations here, such as DB requests - the intention is to speed up the page load, not the opposite.
  • See our default locations for examples.
  • This can improve the extension’s performance and will be appreciated by the users.

5. Load language file.
  • If inheriting from \phpbb\ads\location\type\base, the language file must contain two language keys:
  • AD_<location id>
  • AD_<location id>_EXPLAIN
  • You can define these in any language file and load your language file by any means in your extension.
  • If you do not already have any language files in your extension, or want to load a language file just for your ad locations, you may do so by adding it to your location class constructor, for example:

Code: Select all

public function __construct(\phpbb\user $user, \phpbb\language\language $language)
        {
            parent::__construct($user, $language);
            $this->language->add_lang('locations', 'demo/extension');
        }
6. Add template event. Simply create a template event for the desired position and add this code into it:

Code: Select all

{% set PHPBB_ADS_STYLE = 'margin: 0;' %}
    {% set PHPBB_ADS_CODE, PHPBB_ADS_ID = AD_DEMO_EXTENSION_LOCATION_NAME, AD_DEMO_EXTENSION_LOCATION_NAME_ID %}
    {% include '@phpbb_ads/phpbb_ads_default.html' ignore missing %}
  • Use PHPBB_ADS_STYLE to give your advertisement container a customized set of CSS.
  • Regarding PHPBB_ADS_CODE and PHPBB_ADS_ID, you should not alter the logic of these variables as they are used internally within the default ads template file - simply use AD_ prefix, your capitalized result of get_id(), and append the second one with _ID.
  • Note the ignore missing is an important function that will allow your extension to work even if phpbb/ads is disabled or uninstalled.
7. You are done!

a. Enable your extension.
b. Head to ACP -> Extensions -> Advertisement Management -> Manage Advertisements -> Add new advertisement, scroll down to Locations and you should see your new location present and functional.

8. Bonus: If you want to prevent people from being able to install your extension if phpBB’s Advertisement Management extension is not installed yet, add the following to your ext.php:

Code: Select all

public function is_enableable()
    {
    	return $this->container->has('phpbb.ads.listener');
    }
demo.zip
You do not have the required permissions to view the files attached to this post.
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Will install this later today.

If it's just show it on index only you could just use an if statement to do it.
Use this to install an ext on your board no more ftp or path making.
Path too install this ext is ext/boardtools/upload
Download is here Make it easy for us to solve your issues
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

Probably it would work, but I guess I'm doing something wrong...
I would be very grateful if you could find any solution to display banners only on the front page. :buigen:
User avatar

ivailo95
Users
Users
Magic user status: Offline
Posts: 787
Joined: Feb 2nd, '18, 11:04
    Windows 7 Firefox

Re: Extending Advertisement Template Locations

Post by ivailo95 »

User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

ivailo95 wrote: Mar 23rd, '20, 11:09 try this one
Exchange of banners
That's not quite it. On phones, banners are incomplete and appear outside the front page. Two banner options are few.
Otherwise interesting solution, Thanks! :thumbup:
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

Has anyone had time to try it? :smile:
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Yes i have where is the original files ? the ext.php will not install.
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

Original files.
ads.zip
You do not have the required permissions to view the files attached to this post.
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Like this ? http://www.the-chinese-diesel-heater-community.com/ i used a logo image and it only shows on the index.
User avatar

dmzx
Founder
Founder
Magic user status: Online
Posts: 5975
Joined: Jan 13th, '14, 20:45
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by dmzx »

martin wrote: Mar 25th, '20, 12:32 Like this ? http://www.the-chinese-diesel-heater-community.com/ i used a logo image and it only shows on the index.
looks ok on index only.
binance.com ;) try it!
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Try this every thing is set to show on index only also now installs on 3.3 aswell.
phpbb_ads_2_0_3.zip
You do not have the required permissions to view the files attached to this post.
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

Looks like it works. :tumbsyes:
Will it work through this phpbb ads ext?

Otherwise I would have liked that:
Image
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Try it and see i dont use add's so dont know a great deal how they work.
User avatar

Topic Author
Exabot
Users
Users
Magic user status: Offline
Posts: 47
Joined: Mar 22nd, '20, 11:59
    Windows 10 Chrome

Re: Extending Advertisement Template Locations

Post by Exabot »

After Header Navbar - This option does not hide the banner. Others works perfectly! :thumbup:
I'll try more in the evening.

What exactly did you change? Then I know if I need to adjust.
picture2.JPG
You do not have the required permissions to view the files attached to this post.
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4794
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Extending Advertisement Template Locations

Post by martin »

Cool il fix that one too and give new files.