Talk:Site development: Difference between revisions
(→Blog pages max width and font size: new section) |
(→Common header for Blog namespace: new section) |
||
Line 6: | Line 6: | ||
</div> | </div> | ||
== Common header for Blog namespace == | |||
ChatGTP suggests: | |||
<pre>To include a template at the top of every page in a specific namespace in MediaWiki, you can use the `MediaWiki:Common.js` or `MediaWiki:Common.css` to add JavaScript or CSS that injects the template. Alternatively, you can use the `MediaWiki:CommonHeader` page if it’s supported in your MediaWiki installation. | |||
Here’s a method using JavaScript: | |||
1. **Edit `MediaWiki:Common.js`**: | |||
- Go to the page `MediaWiki:Common.js` on your wiki. | |||
- Add the following script: | |||
```javascript | |||
// Add template to the top of every page in a specific namespace | |||
$(document).ready(function() { | |||
// Replace '3000' with your namespace number | |||
if (mw.config.get('wgNamespaceNumber') === 3000) { | |||
// Replace 'Template:YourTemplateName' with the template you want to include | |||
var template = '{{YourTemplateName}}'; | |||
// Create a new div to hold the template | |||
var templateDiv = $('<div></div>').html(template); | |||
// Prepend the template to the content | |||
$('#content').prepend(templateDiv); | |||
} | |||
}); | |||
``` | |||
2. **Edit `MediaWiki:Common.css`** (Optional): | |||
- Go to the page `MediaWiki:Common.css` on your wiki. | |||
- Add any additional CSS to style the injected template if necessary. | |||
Here’s a method using the `MediaWiki:CommonHeader` page (if supported): | |||
1. **Create `MediaWiki:CommonHeader` for the specific namespace**: | |||
- Go to the page `MediaWiki:CommonHeader/Namespace_3000`. | |||
- Add the template you want to include at the top of every page: | |||
```plaintext | |||
{{YourTemplateName}} | |||
``` | |||
This method might require your MediaWiki to have the necessary extensions or configurations to support namespace-specific headers. | |||
### Explanation: | |||
- **JavaScript Method**: This script checks if the current namespace matches the specified number (`3000` in this case). If it does, it injects the specified template at the top of the content area. | |||
- **CommonHeader Method**: This approach uses MediaWiki’s built-in capabilities (if available) to add a common header to all pages in a namespace by creating a `MediaWiki:CommonHeader/Namespace_X` page. | |||
Choose the method that best fits your MediaWiki configuration and your level of access to the site's backend. | |||
</pre> |
Revision as of 11:30, 23 May 2024
Blog pages max width and font size
resolved via Common.css < see notes there issue was mobile was not liking the center and margin 0 auto and pushed text to the left FIX: make the css rule only for screns ove 850 << see common.css
Common header for Blog namespace
ChatGTP suggests:
To include a template at the top of every page in a specific namespace in MediaWiki, you can use the `MediaWiki:Common.js` or `MediaWiki:Common.css` to add JavaScript or CSS that injects the template. Alternatively, you can use the `MediaWiki:CommonHeader` page if it’s supported in your MediaWiki installation. Here’s a method using JavaScript: 1. **Edit `MediaWiki:Common.js`**: - Go to the page `MediaWiki:Common.js` on your wiki. - Add the following script: ```javascript // Add template to the top of every page in a specific namespace $(document).ready(function() { // Replace '3000' with your namespace number if (mw.config.get('wgNamespaceNumber') === 3000) { // Replace 'Template:YourTemplateName' with the template you want to include var template = '{{YourTemplateName}}'; // Create a new div to hold the template var templateDiv = $('<div></div>').html(template); // Prepend the template to the content $('#content').prepend(templateDiv); } }); ``` 2. **Edit `MediaWiki:Common.css`** (Optional): - Go to the page `MediaWiki:Common.css` on your wiki. - Add any additional CSS to style the injected template if necessary. Here’s a method using the `MediaWiki:CommonHeader` page (if supported): 1. **Create `MediaWiki:CommonHeader` for the specific namespace**: - Go to the page `MediaWiki:CommonHeader/Namespace_3000`. - Add the template you want to include at the top of every page: ```plaintext {{YourTemplateName}} ``` This method might require your MediaWiki to have the necessary extensions or configurations to support namespace-specific headers. ### Explanation: - **JavaScript Method**: This script checks if the current namespace matches the specified number (`3000` in this case). If it does, it injects the specified template at the top of the content area. - **CommonHeader Method**: This approach uses MediaWiki’s built-in capabilities (if available) to add a common header to all pages in a namespace by creating a `MediaWiki:CommonHeader/Namespace_X` page. Choose the method that best fits your MediaWiki configuration and your level of access to the site's backend.