Alerts are thrown into the log if commerce_discounts is enabled on a site that does not have the 'full_html' or 'filtered_html' text formats. This may not be the common occurrence for many sites especially if they install Drupal using the standard install profile, however I have a few custom sites and there are some distributions that create their own text formats and don't use the out of the box text formats.
View: commerce_discount_overview
$handler->display->display_options['footer']['area']['content'] = 'Access to <a href="/admin/config/workflow/rules?event=0&tag=Commerce+Discount">promotion rules</a>';
$handler->display->display_options['footer']['area']['format'] = 'full_html';
$handler->display->display_options['empty']['area']['content'] = 'No discounts found.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
Comments
Comment #1
grahamvalue commentedGetting a similar alert in the log:
Type filter
Date Friday, October 3, 2014 - 11:09
User Serenity
Location http://www.serenitystocks.com/admin/commerce/orders/carts
Referrer http://www.serenitystocks.com/admin/commerce/orders
Message Missing text format: plain_text.
Severity alert
Hostname 117.192.148.64
Operations
Screenshot attached.
Thanks!
Comment #2
grahamvalue commentedPlease note:
1. Site was upgraded from Drupal 6.
Text format machine names are stored as numbers, not as names.
2. Site does not have Commerce Discount module installed.
But the error/alert is the same so logging it here for reference.
Thanks a lot!
Comment #3
ralt commentedI tried to use the attached patch, but it raises another issue: the link to promotion is in plain text. See attached picture.
What should be done? Should the module force these text formats to exist?
Another thing to note is that the patch modifies a bit of featured code (the exported view): it shouldn't do that. The patch is just there for the sake of the example.
Comment #4
caschbre commentedHmm... maybe we don't put the link in the View? And add it off of the navigation? Or we would have to write a View plugin that can render the text instead of adding it to the footer.
Comment #5
ralt commentedI don't see how we can not show the link. It's a feature.
I thought about it for a while, and the best solution I could come up with was to use
variable_get('...', 'full_html'). It'd allow websites with default formats to keep working normally, and users with special setups could configure this. What do you think?Comment #6
caschbre commentedyeah, I don't mean to remove the link... was just thinking if we could put it somewhere else that doesn't rely on the text format.
Not sure if we need a variable. I think if a module/site needs to change the view to work around a missing format they can just use hook_views_default_views_alter. I was hoping to avoid that for something like a text format but that seems like the only option unless we move the link elsewhere.
What if we added a hook_menu that throws up the "Promotion Rules" as a tab (redirect) on the admin/commerce/store/discounts page? That would put "Promotion Rules" as a tab and when the user clicks on it, it just redirects them to the actual link needed?
Comment #7
ralt commentedI like that idea. The other text format doesn't have a link in it, so it's not very important to keep it as such. I'll see if I can do it during the day.
Comment #8
ralt commentedThere we go! The following patch adds a new tab "Promotion rules" that redirects to the rules page.
Comment #9
ralt commentedFixes styling and removes unneeded code.
Comment #10
caschbre commentedLooks good! Thanks Ralt!
Comment #11
caschbre commented@Ralt... I'm using this patch and it looks good. I haven't seen the warnings anymore.
Comment #12
rsvelko commentedThis is wrong.
Should be with a space and not "+"
RIGHT :
+ 'tag' => 'Commerce Discount',
So I attach the newest patch.
I also think the "Promotion rules" title should say something more intuitive like:
"Rules with tag: Commerce Discount"
or
"Commerce Discount Rules"
or
"Discount Rules"
Anyway please commit whatever asap. I've not changed the wording in my attached patch.
Comment #13
rsvelko commentedbtw, I am applying for a co-maintainer so I can commit several fixes myself. Wish me luck.
Comment #15
bojanz commentedRenamed the tab to "Discount rules", it's weird that the word Promotion was used when it's "Discount" everywhere else in the module. Also moved the tab to be last.
In the future I'd like to make that tab less prominent, maybe move it under Settings. In any case, this patch was a step in the right direction.
Thanks for testing, everyone.
EDIT: Hm, looks like d.o didn't recognize Ralt's authorship :(