Advertisement Management

Display banner on main page? - Advertisement Management

Display banner on main page?

by Exabot » Tue Dec 10, 2019 12:11 pm

How to display only the main page?
Exabot
Translator
Posts: 181
Joined: Sun Jan 18, 2015 8:21 pm
Location: Estonia
Contact:

Re: Display banner on main page?

by Gretzn » Tue Jan 28, 2020 4:42 am

I wish too there is a option to show it only on the start page, or better: That you can choose where to show it or not.
User avatar
Gretzn
Registered User
Posts: 11
Joined: Sat Jan 26, 2019 9:28 pm
Contact:

Re: Display banner on main page?

by DavidIQ » Wed Jan 29, 2020 10:28 pm

Extend the template locations using one of the template events that are only present in index_body.html.
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 17164
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Re: Display banner on main page?

by Gretzn » Wed Jan 29, 2020 11:24 pm

Thank you.
User avatar
Gretzn
Registered User
Posts: 11
Joined: Sat Jan 26, 2019 9:28 pm
Contact:

Re: Display banner on main page?

by Exabot » Thu Mar 12, 2020 7:04 am

Why not add an index_body.html option to the module now?

Can anyone help me with this?
Exabot
Translator
Posts: 181
Joined: Sun Jan 18, 2015 8:21 pm
Location: Estonia
Contact:

Re: Display banner on main page?

by Exabot » Fri Mar 13, 2020 8:08 am

Since support doesn't help much, maybe someone else can help ...
If no one is bothered to help in this way then maybe someone bother to do the zip ready?

1. config/services.yml

Code: Select all

phpbb.ads.location.type.new_name:
    class: phpbb\ads\location\type\new_name
    arguments:
        - '@user'
        - '@language'
    tags:
        - { name: phpbb.ads.location.type }
It is okay?

2. Add a location type class in location/type/ directory, for example location_name.php.

new_name.php
It is okay?

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 'new_name';
}
It is okay?

4. Implement optional method will_display(). If your location is not present on every page, we strongly encourage you to implement this method.

\phpbb\ads\location\type\type_interface at the end:

Code: Select all

public function will_display();
}
How and where do I add:
  • 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.
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
What exactly do I do with them?

\phpbb\ads\location\type\base includes:

Code: Select all

public function __construct(\phpbb\user $user, \phpbb\language\language $language)
	{
		$this->user = $user;
		$this->language = $language;
	}
Do I have to make this part like that?

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:
phpbb\ads\styles\all\template\event\overall_footer_copyright_prepend.html

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 %}
This last one will stay that way?
Exabot
Translator
Posts: 181
Joined: Sun Jan 18, 2015 8:21 pm
Location: Estonia
Contact:

Re: Display banner on main page?

by DavidIQ » Fri Mar 13, 2020 9:01 am

Exabot wrote:Since support doesn't help much, maybe someone else can help ...
There are instructions to do this properly and we provided them already. Instead you've decided to study the extension and modify it to your needs, which is fine, but we won't provide support for that. Sorry.
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 17164
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact: