Skip to content

Commit b05d7bd

Browse files
Merge pull request #551 from SuffolkLITLab/copilot/fix-550
Add favicon customization documentation to ALThemeTemplate overview
2 parents 959250d + 955ceb2 commit b05d7bd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/components/ALThemeTemplate/althemetemplate_overview.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,37 @@ Your new `custom.css` file is in the
178178
`~/bootstrap-5.1.3/dist/css` directory. Copy this file to your Docassemble
179179
`static` folder and reference it as a `bootstrap theme`.
180180

181+
### Overriding the favicon for a single interview
182+
183+
Docassemble's global configuration only allows you to define the favicon server-wide,
184+
but sometimes you have a reason for a single interview to use a different one.
185+
186+
You can override the favicon at runtime by loading a custom JavaScript file in your interview:
187+
188+
```javascript
189+
$(document).on('daPageLoad', function(){
190+
var link = document.querySelector("link[rel*='shortcut icon'") || document.createElement('link');
191+
link.type = 'image/x-icon';
192+
link.rel = 'shortcut icon';
193+
link.href = "/packagestatic/docassemble.YourPackage/your_favicon.svg?v=2023_02_04_1";
194+
document.getElementsByTagName('head')[0].appendChild(link);
195+
});
196+
```
197+
198+
To use this:
199+
200+
1. Create a JavaScript file (e.g., `favicon.js`) in your package's `data/static` folder with the code above
201+
2. Customize the SVG filename in the `link.href` line, replacing `YourPackage` with your package name and `your_favicon.svg` with your favicon filename
202+
3. Add the JavaScript file to your interview's `features` block:
203+
204+
```yaml
205+
features:
206+
javascript:
207+
- favicon.js
208+
```
209+
210+
The favicon will be updated whenever a new page loads in your interview, overriding the server's default favicon for that specific interview only.
211+
181212
### Using dark mode
182213

183214
Docassemble by default will show an alternate "dark mode" version of your interview to

0 commit comments

Comments
 (0)