Web based family history software

Solved Creating a link to a css file in a module

More
2 weeks 1 day ago #1 by RickM
I have modified Just Carmens 'Simple Footer' module to suit a footer I have created for my site and those of a colleague.. Currently the module has no link to a css file within the modules folders eg resources/css/alm-footer.css

How do I add such a link within the module.php file??

Thanks in advance..
 

Rick M
Tauranga
New Zealand - Nu Tirani

alineofmalkins.com/wt-malkins
Webtrees v2.1.20
Hosted by HostAmarada on litespeed Server, PHP v8.2

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago - 2 weeks 1 day ago #2 by Franz Frese
Replied by Franz Frese on topic Creating a link to a css file in a module
use something like 

$this->assetUrl('css/my.css')

where my.css is in <your-module>/resources/css

put that into the function:
    public function stylesheets(): array
    {
        return [
            $this->assetUrl('css/my.css'),

        ];
    }
Last edit: 2 weeks 1 day ago by Franz Frese.

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago - 2 weeks 1 day ago #3 by Jefferson49
Replied by Jefferson49 on topic Creating a link to a css file in a module

I have modified Just Carmens 'Simple Footer' module to suit a footer I have created for my site and those of a colleague.. Currently the module has no link to a css file within the modules folders eg resources/css/alm-footer.css

How do I add such a link within the module.php file??

 
You need to take several steps. Maybe, it helps to have a look at an existing custom module :
  1. Let the class implement the ModuleGlobalInterface
  2. Add a method to return the ressources folder , where you put your css file
  3. Add a  method to include the css within the head of the html page
Last edit: 2 weeks 1 day ago by Jefferson49. Reason: Link is wrongly shown

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago - 2 weeks 1 day ago #4 by RickM
Replied by RickM on topic Creating a link to a css file in a module
Thanks to both Franz & Jefferson49 for your input.

I have had errors using each suggestion, however I will continue to 'fiddle' and learn/understand things better..

Should I find myself not getting anywhere I will come back for more advise..

Many Thanks..

Addendum: After rechecking code etc, I find the error in my ways.. Appears to be working using Jefferson49's solution..
 

Rick M
Tauranga
New Zealand - Nu Tirani

alineofmalkins.com/wt-malkins
Webtrees v2.1.20
Hosted by HostAmarada on litespeed Server, PHP v8.2
Last edit: 2 weeks 1 day ago by RickM. Reason: Solution sorted

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago #5 by Jefferson49
Replied by Jefferson49 on topic Creating a link to a css file in a module
For a default implementation of the methods of the ModuleGlobalInterface, you might need to include the corresponding trait, e.g.

use ModuleGlobalTrait;

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago #6 by RickM
Replied by RickM on topic Creating a link to a css file in a module
Thanks Jefferson49, I did add that along the way, but the implementation was not complete..

Many Thanks to you and Franz..

I love this forum and Webtrees!

Rick M
Tauranga
New Zealand - Nu Tirani

alineofmalkins.com/wt-malkins
Webtrees v2.1.20
Hosted by HostAmarada on litespeed Server, PHP v8.2

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum