How to modify the front-end template in ckan-docker? #157
-
Hello @mjanez, I'm currently working with the ckan-docker setup and would like to customize the front-end template. Could you please guide me on how to proceed with modifying the template? Any help or pointers would be greatly appreciated. Thank you for your time and assistance! Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi Marco, to customize the front-end template in CKAN using the ckan-docker setup, the best approach is to create a CKAN extension where you can override templates, add custom styles, and implement any additional frontend logic you need. Here are the basic steps for developing a custom theme in CKAN:
Cheers! |
Beta Was this translation helpful? Give feedback.
-
Hi, I tried to add a custom plugin from a git repository. I followed all your instructions, but the result is always the same. My plugin doesn't override the scheming template, and my team and I can't figure out why. Could you help us out? We have verified that the custom plugin is correctly loaded inside the ckan_dev container in the src_extensions folder, but the template located in /srv/app/src/ckan/ckan/templates is still the one from scheming. |
Beta Was this translation helpful? Give feedback.
-
I try to help you, Here’s how you can adjust your setup:
In your ckan.ini, ensure that scheming is not explicitly listed in the ckan.plugins section. You’ll only load your custom plugin that inherits from scheming. Example: ckan.plugins = your_custom_plugin
from ckanext.scheming.plugins import SchemingDatasetsPlugin
import ckan.plugins as plugins
class CustomSchemingPlugin(SchemingDatasetsPlugin):
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IConfigurable)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IDatasetForm, inherit=True)
plugins.implements(plugins.IActions)
plugins.implements(plugins.IValidators)
def read_template(self):
# Override the default read template
return "your_custom_plugin/package/read.html"
def resource_template(self):
# Override the default resource template
return "your_custom_plugin/package/resource_read.html"
def package_form(self):
return "your_custom_plugin/package/snippets/package_form.html"
def resource_form(self):
return "your_custom_plugin/package/snippets/resource_form.html" This approach ensures that CKAN will use your custom templates (
def update_config(self, config):
# Add the custom templates directory to CKAN's search path
plugins.toolkit.add_template_directory(config, 'templates') If you run into any more issues, feel free to reach out. |
Beta Was this translation helpful? Give feedback.
I try to help you,
ckanext-scheming
is a bit unique in that you need to leverage its schema system but still want to override its templates. For this, you have to load scheming in yoursrc/
directory - development mode- but avoid including it…