wintercms / wn-pages-plugin

Static Pages plugin for Winter CMS
https://wintercms.com/
MIT License
9 stars 21 forks source link

Feature request: Static links #6

Closed multiwebinc closed 2 years ago

multiwebinc commented 2 years ago

I thought it might be useful to be able to define a list of external URLs that can be used throughout the website. Maybe let me start with an example when I think this might be useful:

Say you have a personal website and you want to put a link to your LinkedIn page in the main menu, in the page's footer, on the home page, on the contact page, and randomly located on several other pages on your website.

All of those would have to be hard-coded in the source code with the URL. Therefore, any changes to that URL would require a search and replacement of all the places it could be in your source code, which could be error-prone. Also, the URLs themselves might be too long to remember. So my idea is to add something called "Static links" to this plugin. You would define a series of URLs with their respective ID (code). Then to link to that URL anywhere, you would do something like:

{{ 'linkedin'|link }}

Also, in the menu editor section of this plugin add a "Static link" type.

Would you guys think something like this would be useful to add?

LukeTowers commented 2 years ago

See https://wintercms.com/docs/themes/development#customization, that should cover that use case just fine.

multiwebinc commented 2 years ago

Thanks, @LukeTowers. Yes, that's definitely along the lines of what I was going for. About the part of putting it in the menu editor, would you think that a "Theme configuration value" type would be useful?

LukeTowers commented 2 years ago

@multiwebinc not really. If you're really just using it for a list of links then I would probably even forego theme settings altogether and just manage them in a new menu entirely, probably named footer links or something. Then you can render it out using partial overrides or just interacting with the injected page variables directly.

multiwebinc commented 2 years ago

@LukeTowers My use case is a bit more complicated since I need to modify the URL depending on the presence of a cookie value, so I'm using a custom plugin to handle that. But since it doesn't look like anything in this issue would be useful, I'm just going to close it. Thanks for your input.

LukeTowers commented 2 years ago

@multiwebinc no worries, always appreciate hearing about how people are using the project. With regards to a custom reference type for the menus I believe you should be able to register your own through your own plugin, try taking a look at the docs for the plugin and the plugin's code; see how something like the blog posts reference types are supported.

multiwebinc commented 2 years ago

@LukeTowers Yeah, adding reference types is a good idea. However, I already had it done though when I posted my last comment. What I ended up doing was create a plugin that defines a custom markup tag. Then to put it in the menu, I added an item with the type "Header", and in the Twig where the menu is displayed, I check for that specific item and add the link in using the custom markup tag. And any other file that needs the link, I just use the markup tag.