codeigniter destroying session after adding ckeditor latex code in cart - php

I am working on codeigniter project of online exams. I am creating optional question bank.
For adding multiple options i am single ck editor in which after creating option i am inserting option in codeigniter cart.
option is html of ck editor.
But when i am using latex equation in ckeditor as option, i am logging out.
its destroying my user login session. Normal html works fine.
who to overcome this problem?
<Script>
var option_html=CKEDITOR.instances['option'].getData()
$.post(base_url+"question_bank/questions/add_option",
{option_html:option_html,is_correct:is_correct}
,
function(data)
{
//code
}
);
</script>
php code
$data = array(
'id' => uniqid(),
'qty' => 1,
'price' => "1",
'name' => $is_correct,
'options' => array('type' => 'question_option',
'option_id'=>'',
'option_html' => $option_html)
);
$this->cart->insert($data);

i got answer there is no problem of cookie size. change value of product_name_rules in cart to '[:print:]'; change config to use database for session open ckedior/plugins/eqneditor/dialogs/eqneditor.js and remove statement a.setAttribute('alt')

Related

How to make a custom theme using Laravel and where to store theme data?

I'm building a full website Using Laravel and this problem is facing me , I want to give the user full control to the site appearance and the ability to change website's layout without my help.
But when I'm thinking about someway to do so by database , there are several tables with tens of columns will be added beside the colors and sections that will be added to database every time the user will change something in the layout style.
Is there any other way to store the options of the theme in XML file or anything other than database?
** Note : when I checked the database of Wordpress I hadn't found any thing concerned to themes there , So where Wordpress store theme options?
For your XML-like storage you can use Laravel Config. Let's say you have the file config/templates.php. Inside you can have a lot of stuff like.
return [
'default_template' => 'layouts.templates.default',
'posts' => 'layouts.templates.post',
'footer' => 'layouts.includes.footer',
'options' => [
'full_with' => false,
'has_footer' => true,
'background_color' => '#fff',
'more_keys' => 'key_value'
]
];
Then anywhere in your app you can get the default template like
$view = config('templates.default_template'); //will get
return view($view, compact('params'));
To update a key, like has_footer, you do
config(['templates.options.has_footer' => false]); //will update
This should get you started I think
Simple Example
Let's say user changes default colour from and input and submit the form. You do
public function updateTheme(Request $request) {
if ( $request->has('background_colour') && $request->background_colour != '' ) {
config(['templates.options.background_colour' => $request->background_colour]);
}
}

How to correctly create function for formatter on PHP in Yii2 Highcharts extension

I have to display some special information when my mouse is over a concrete point in a chart that is provided by Highcharts. I am using the Highcharts extension for Yii2.
My Code
'tooltip' => [
'enabled' => true,
'footerFormat' => true,
'formatter' => "js:function() {
return 'my special information';
}"
],
The data that comes from controller is correct.
However there is nothing different - tooltip is still the default
What am I doing wrong?
Sorry. My bad. All is working fine. I just duplicate 'tooltip' option. And my tooltip that i want to use was override by tooltip that i forgot to remove from my code)

CKEditor not displaying data in CakePHP

I am using CKEditor plugin in CakePHP like this :
$this->element('ckeditor', array(
'name' => 'body',
'description'=>$body,
'id' => 'description',
'width' => 628,
'height' => 250
));
But I am unable to see the content on page load.
$instructionDetails['Instruction']['body'] contains html data. I tried static data also and its displaying in it but not html data.
On changing language I am able to see the content since I am using:
CKEDITOR.instances.description.setData(data);
in the JavaScript change event. Is there way to use setData in $this->element('ckeditor') with other params?
You need to tell ckeditor to open in which default mode. The mode to load at the editor startup depends on the plugins loaded. By default, the "wysiwyg" and "source" modes are available.
Use This
CKEDITOR.config.startupMode = 'source'
CKEDITOR.instances.config.startupMode = 'source'
What it will is open the data as source to you.

how to create a custom drupal 7 edit page

Im a TOTAL newbie to drupal development so please help me here, ok i have created a custom module which so far creates a custom database how do i go about creating a list page in the backend that i can use to manage each item in the DB and how do i go about creating a custom edit form to manage the insert/ edit / delete of each item
function rollover_res_schema() {
$rollover_res = array();
$rollover_res['rollover_res'] = array(
// Example (partial) specification for table "node".
'description' => 'Positioning for rollovers',
'fields' => array(
'rollover_res_id' => array(
'description' => 'The primary identifier for a node.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'rollover_res_actual' => array(
'description' => 'The main rollover plain text.',
'type' => 'text',
'length' => 255,
'not null' => TRUE,
),
),
'indexes' => array(
'rollover_res_id' => array('rollover_res_id'),
),
'primary key' => array('rollover_res_id'),
);
return $rollover_res;
}
If you're a total newbie to Drupal development you should not be writing ANY code for the first month or two and you shouldn't do custom database code the first 6 months.
Start with learning about Fields and Views and once you grasp these you can add one of Display Suite, Context or Panels.
The key to learning how to do things in drupal is:
1) google search how
2) see how other modules do it. In this case, look at some core modules, such as the block module. In there you'll see the schema in .install, and you'll see some functions that create forms for saving new blocks, such as block_add_block_form. You'll need to read up on the form API. But basically, you'll create a form hook to display a form, a menu hook to create a page to hold the form, and a hook to submit the form. If you grep through your code base, you'll see many of examples that you can copy. In fact, there are drupal example modules you can download that cover most of the basics: https://www.drupal.org/project/examples
But to learn how to interact with the database, you could find a module that does something similar to what you're doing and look at how it uses hook_menu to set up page callbacks, forms for editing data.

Aptana PHP Formatter - use custom formatting rules

I'm using Apatana's formatting features in PHP documents, it works well except with arrays where it transform this:
$data = array(
'email' => $params['email'],
'username' => $params['username'],
);
into this:
$data = array('email' => $params['email'], 'username' => $params['username']);
is there a way to avoid this and set custom formatting rules?
Yes. There is a way.
Go to the Studio's preferences and locate the 'Formatter' item. If you are using the default formatter profile, create a new one by clicking the '+' icon.
Click to edit the PHP formatting setting (double-click the 'PHP' item, or click it and than click the 'Edit' button).
Under the 'New Lines' tab, check the option to 'Insert new line between array-creation elements'. OK the dialogs. Make sure that the profile you just created is the selected one in the formatter preferences page, and format your code.
Cheers

Categories