python - Customising the Link plugin -
i building multi-site django website. able override functionality of base link plugin cms.plugins.link
able link other page within of other sites.
i'm using default editor, wymeditor.
i have created custom cmsplugin abstract model provides functionality need using cms.models.fields.pagefield
class , using within bespoke plugins.
what i'm unsure how (or if) can either change existing cms.plugins.link
model or somehow extend this. need have modified plugin available within available plugins list in simple cms.plugins.text
instance.
for it's worth, code custom plugin follows:
class pluginwithlinks(models.model): """ there number of plugins use links other on-site or off-site pages or offsite. information abstracted out here. extend class if need class has links core part of functionality. """ page_link = pagefield( verbose_name="page", help_text="select existing page link to.", blank=true, null=true ) url = models.charfield( "link", max_length=255, blank=true, null=true, help_text="destination url. if chosen, used instead of \ page link. must include http://") link_text = models.charfield( blank=true, null=true, max_length=100, default='more', help_text='the \ link text displayed.') target = models.charfield( "target", blank=true, max_length=100, choices=(( ("", "same window"), ("_blank", "new window"), ("_parent", "parent window"), ("_top", "topmost frame"), )) ) class meta: abstract = true @property def link(self): if self.url: return self.url elif self.page_link: full_url = "http://%s%s" % ( self.page_link.site.domain, self.page_link.get_absolute_url() ) return full_url else: return ''
i think i've found answer: https://stackoverflow.com/a/5700886/378136
i'd suggest keeping post else same query.
Comments
Post a Comment