Composite C1: how to make the page editor to display the source code by default - c1-cms

When you start editing a page, the editor is initially in the Visual mode, so every time you have to switch it to the Source mode if you prefer html-level editing as usually programmers do.
It is annoying when you have a lot of things to do during the day, especially when there is a bunch of languages every page is translated to.
I haven't found any option in the CMS and no solution in Google.
Actually I found myself the way to change this, so I post this question in order to instantly answer it. Maybe this will help somebody.

Edit file VisualEditorPageBinding.js, which is located in /Composite/content/misc/editors/visualeditor/bindings.
There is function VisualEditorPageBinding.prototype.initializeComponent.
Simply add this line at the very end of the function:
this.switchEditingMode();

Related

Can you get good code from Anima in Sketch?

I have a twofold type question regarding Anima's export to code feature in Sketch.
As a designer it's tempting to think of your work straight to code but, the reality is it doesn't quite work like that. 
So, the first part of my question is: how good/reliable you think that code is?
The second part is an ask for help with the code.
So, I've created this super simple 2-page random quote generator in Sketch to call out bullshit on the President of Brazil (the crap the guy says...). I designed 3 breakpoints and all that but now that the code is here, I don't know how to do simple things like adding links to the buttons. 
Plus, when you click the big green button on the homepage you should be taken to the results.html where a .js is going to generate a sentence.
The .js is ready to go.
Here's the prototype link: https://winter-glade-8944.animaapp.io
Anima is already in its first age , the big problem that most of time , it will be stuck in one page , and you can't get the code of other pages ,
the best solution is to duplicate your project on Figma , then extract the first page's code , then delete this page from anime , then generate the code for the second page ,, and so on

Add CSS to whitelist - border-radius, opacity, text-shadow

Starting off, I have very little understanding of the PHP or how HTMLPurifier itself works and am completely learning on the go. I've got a fair understanding of HTML and CSS from teaching myself, but I wouldn't call myself anything more than a novice at this point.
I run a myBB forum via hostgator wherein my users want HTML allowed to make fancy tables for their posts. Since we only opened shop a month ago and have a very small userbase so far of people I know and trust, I enabled HTML. About a week ago I used a plugin plus the current library to install HTMLPurifier into my forum. It works great. Thing is, it eats up a majority of the code my users are using to make their posts look good.
I tried to plug this code which I found here into my CSSDefinition.php file between the border-color and border-width codes to try to fix the border-radius issue.
// border-radius
$border_radius =
$this->info['border-top-left-radius'] =
$this->info['border-top-right-radius'] =
$this->info['border-bottom-left-radius'] =
$this->info['border-bottom-right-radius'] = new HTMLPurifier_AttrDef_CSS_Composite(array
(
new HTMLPurifier_AttrDef_CSS_Length('0'),
new HTMLPurifier_AttrDef_CSS_Percentage(true)
)
);
$this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius);
That did absolutely nothing, I assume because his is out of date. I haven't been able to find any information on adding text-shadow to my whitelist, nor how to allow opacity, either through opacity:#; or rbga(#,#,#,0.5), though I did find a hack for the latter that I couldn't make heads or tails of for what to actually do with the file.
I don't know how to run my Config.php file because looking at the code I can see there is information there, but trying to visit the page through various means gets me nowhere.

How to add a custom field into template.php using Zen sub theme

First time poster here, I'm a designer not skilled at all with php and I have a small issue I don't seem to be able to solve. I'm making a site in drupal 7 using a sub theme on zen.
Btw this is a great CMS, even though people say it's really more a developers CMS. I have no trouble to do what I need using views, rules, display suite etc. So a big thank you for all the developers out there making this such a good CMS. But for this apparently simple problem... no module will help me (I think) and I'm kinda stuck.
So here it is: I'd like to add a subtitle next to the title in all my pages.
So what I did was to add a custom field into the content type basic page (machine name: field_sub_title) which is a simple text field.
I uncommented the following line in my template.php
function mytheme_preprocess_page(&$variables, $hook) {
$variables['sub_title'] = t('field_sub_title');
}
Now my question is how do I load the content of my custom field into that variable?
I know i need to change the second part, but I don't have a clue as into what I need to change this.
Displaying the variable into the the page.tpl.php is something I know about so I only need help with the first part.
{EDIT}
Ok I found how to do this :)
I was looking for a solution in the wrong place. I don't need to change any thing in the template.php file.
Just needed to add this bit of code into my page.tpl.php:
<?php
print $node->field_sub_title['und'][0]['value'];
?>
So I'm posting this here for other Drupal newbies struggling with this....
Your solution may work for now, but there may be a more Drupal-y way to handle a problem like this. If you haven't noticed any problems yet, you may find one or more of the following issues down the road:
Someone who doesn't know php or Drupal theming may need to change the way this works.
If you're like me, you may forget where exactly in code this was implemented.
You may see superfluous markup and/or errors on nodes (content) that do not have this sub-title field (ie. event content not having a sub-title field while basic pages and news articles do).
When you add a field to a content type, it will automatically appear anytime content in that content type is displayed. You should be able to add the sub-title field for your page, event or whatever else you need and have it automatically appear in the markup.
You can 'manage display' of a content type to drag and drop the order for fields to appear. You could take it a step further by using a module like Display Suite to add formatting or layout per-content type.
If you feel like this isn't good enough and the markup for the subtitle must be at the same level as the page title (which is rare), at least add an if statement to make your code check to see if the variable is present before trying to print it. I'd also add a new variable and comments for code readability.
<?php
$subtitle = $node->field_sub_title['und'][0]['value'];
if($subtitle){
print $subtitle;
}
?>
Consider using field_get_items or field_view_value, or at least use the LANGUAGE_NONE constant instead of 'und'
See https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7 and https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_value/7
This has the added benefit of reducing the number of potential security holes you create.

Storing a textarea's value into a database table

How can you get the value of a <textarea> and store it in a MySQL database table?
I'm using TinyMCE 3.3.9.3.
Seeing as no one has answered your question I thought I'd chip in. Have you ever managed to get any form data passed into a database before (I.E is it just accessing a textarea that's the problem), or is this a general question about how to put form data into databases?
One thing I would strongly recommend is moving away from WYSIWYG style editors if your seriously considering doing web development properly. From experience no matter how good they claim to be you'll always encounter cross browser problems and at some point you'll have to dig into the code and understand it.
Sorry this isn't a direct answer, but with a bit more info as to what you need to know I'm sure we can help... I warn you though, if you've not had much experience at this some of the answers could be a bit deep. I think maybe this is why you've not had any responses because the answer require could potentially be quite epic,lol.
Dan
The tinymce editor id equals the textarea id.
Assuming that editor is your tinymce editor instance you may use the following to get the textareaa content (which is then equal to the editor content).
editor.triggerSave(); // update the textarea
var textarea_element = document.getElementById(editor.id); // get the updated textarea
var content = textarea_element.innerHTML; // this is the content
// now you need to call a script to save the content (i suggest you use ajax)
...

DNN: Registered Mark changing to Question Mark

I am having a problem with registered marks in the HTML module.  We need to use the Registered Trademark symbol (®) but some of them are being changed to question marks.  I can find no ryme or reason behind which change and which remain correct.  I have tried a number of things to fix this issue including the following:
Using ® and ®
using <sup>®</sup>
copy and paste of ® in both source and non source
and using the "insert special character" from the RTE menu
Some of the symbols remain but most revert back to question marks.  If i'm in edit mode, the questions marks change back to the registered mark.  Also sometimes the first time viewing the page not logged in or in view mode, they will look fine. But as soon as I got to edit mode or a new page then go back, they change back to question marks.  I am out of idea as to why this is happening.
You can see the page at: http://fasttracsc.twif.net/AboutFastTracSC.aspx  Anywhere you see Fasttrac? it should be Fasttrac®
Any help anyone can provide would be much appreciated.
Thanks in advance.
ok i have found the problem. The Rich Text Editor has a bug ("maybe by design?") that even the source button does not show you raw HTML. The RTE is still rendering the HTML prior to inserting into the database. If you change the RTE to Basic Text Box and edit the HTML there, you are once again able to get a consistent ® symbol using the ® code.

Resources