Fancy box post back problem - fancybox

I,m using fancy box for opening a new aspx page . Before any post back in that page this works perfectly . But if any post backs happens in this page then this page will open in the normal window and not in fancy box.

I think u r using normal option like : Inline - modal window
use iframe option. it will not open in normal window after postback
$("#MyID").fancybox({
'width' : '75%',
'height' : '75%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});

Related

How to link this button to another route in Laravel Bacpack

So i have this view below :
The button view that i want to route to another page
Theres a button named Go To Question that i want to link to edit-question route. This is the code for the button.
[ // CustomHTML
'name' => 'separator',
'type' => 'custom_html',
'value' => '<a href="{{$this->crud->setEditView(`backpack::crud.question`,3);}}"
target="_blank">Go to question ></a>'
],
Does anyone know how to do this ?
You can easily link to a Backpack page using the backpack_url() helper instead of Laravel's standard url(). That will also add the admin prefix that you've set in your config/backpack/base.php (by default admin).
But take note that you cannot add a link to a particular view in Laravel. You should point to a route, that points to a controller, that loads a view. So your button should look more like this:
[ // CustomHTML
'name' => 'separator',
'type' => 'custom_html',
'value' => '<a href="{{ backpack_url('question/3/edit') }}"
target="_blank">Go to question ></a>'
],
This will point to the Questions CRUD route, which will load QuestionCrudController, which in its turn will load the edit view - assuming you do have that CRUD.

tinymce adding p tags automatically?

Im using tinymce and saving it to a database.
When I edit the saved content using tinymce and save again, it inserts a p tag at the beginning.
Editing the content over and over again leaves a large gap at the beginning of the content.
DOes anyone know a fix?
TinyMce automatically add "<p>" in new lines.
You can set this option in tinyMce initialization like this:
tinyMCE.init({
mode : "textareas",
theme : "advanced",
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : '',
});
Hope it will help
Fonski
For me it worked by making "force_br_newlines : true" instead of false.
tinyMCE.init({
mode : "textareas",
theme : "advanced",
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : ''
});
I hope it helps
I am sure that #Fonski answer is correct but thought I would update this for anyone else that did was confused as to where to put the code. I placed the following in my _config.php file to get it to work:
$defaultEditorConfig = HtmlEditorConfig::get('cms');
$defaultEditorConfig->setOptions(
array(
'mode' => 'textareas',
'theme' => 'advanced',
'force_br_newlines' => false,
'force_p_newlines' => false,
'forced_root_block' => ''
)
);
Note: If you just want to remove the p tag that automatically wraps image tags (etc) all you need to set is the 'forced_root_block' => '' option.
EDIT: This advice is for those using SilverStripe, I posted this thinking the questions was SilverStripe specific.
From tinymce.js v4.1.10 code:
newBlockName = (settings.force_p_newlines ? 'p' : '') || settings.forced_root_block;
So the key to avoid <p> seems to be as stated before
settings.force_p_newlines = false
and
settings.forced_root_block = ''

"add products" button missing from admin create order page - magento

We've just upgraded our site from 1.6.X to 1.7.0.2 and encountered this problem, 99% of the site is running fine.
When you go to sales/orders & create new order the "add products" button is missing? ive checked the styles and there is just a blank div where the button should be -
<div class="form-buttons"></div>
I've tried un-installing extensions, re-installing magento 1.7.0.2 from magento connect & i've also manually downloaded / over written the adminhtml folder, none of which have had any effect.
We also installed a fresh copy of magento with a blank database to the same server & the button is present.
Any ideas?
The changes is in the file located here :
/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items.php around line 55
In previous version the getButtonsHtml() function was :
public function getButtonsHtml()
{
$addButtonData = array(
'label' => Mage::helper('sales')->__('Add Products'),
'onclick' => "order.productGridShow(this)",
'class' => 'add',
);
return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addButtonData)->toHtml();
}
The new version is :
public function getButtonsHtml()
{
$html = '';
// Make buttons to be rendered in opposite order of addition. This makes "Add products" the last one.
$this->_buttons = array_reverse($this->_buttons);
foreach ($this->_buttons as $buttonData) {
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData($buttonData)->toHtml();
}
return $html;
}
So now you can have more than 1 button, but the first default button doesn't exists anymore.
I'm not sure how to add it without overwritting this block.

CakePHP 2.0 JSHelper Link don't evoke plugin

I am trying to use the JS helper as shown below:
echo $this->Js->link(
'Incluir'
, array('controller' => 'events', 'action' => 'add')
, array(
'title' => 'Incluir'
, 'update' => '#content-outer'
, 'before' => $this->Js->get('#content-outer')->effect('fadeOut', array('buffer' => false))
, 'success' => $this->Js->get('#content-outer')->effect('fadeIn', array('buffer' => false))
)
);
The result is this ajax and this link below:
link: Incluir
ajax: $j("#link-473478646").bind("click", function (event) {$j.ajax({beforeSend:function (XMLHttpRequest) {$j("#content-outer").fadeOut();}, dataType:"html", success:function (data, textStatus) {$j("#content-outer").fadeIn();$j("#content-outer").html(data);}, url:"\/bilheteria\/events\/add"});
The link opens the method requested, using the fade effect, but i have a tinyMCE plugin in this view and it does not render.
When I call a console and execute the call manually the tinyMCE plugins render properly and when I evoke the link using the complete address http://192.168.50.7/bilheteria/events/add the plugins work as well.
I have tried using all of the following options in the js link:
method - GET / POST / PUT
type - ‘json’
evalScripts - True / False
Why does the the js->link behave in this way? (i.e. rendering the ajax and the link correctly but when the link is used to access the page the tinyMCE plugins are broken?)

PHP : How to get returned link when access a link

I have a problem and I hope you all will help me. I'm using Wordpress. In my country, facebook is banned. So I can't access my Facebook Profile Picture at :
Link A : http://graph.facebook.com/100001225080368/picture -> and facebook will return link B to browser :
Link B : http://profile.ak.fbcdn.net/hprofile-ak-snc4/161159_100001225080368_1270343183_q.jpg
I have an app on my blog. It will connect to facebook and get all data (status, picture, link, like...), and then, display on my blog. The problem is : text data can be displayed but profile picture can't be. That because the code to display profile picture is :
<img src="$fb_pic_id" />
$fb_pic_id in my php code will return Link A -> this link has facebook domain in it and in my country (facebook is banned), the browser can't display and the connect will be timeout after 30s by default.
But if I pass Link B to "src" attr, the profile picture will be displayed. But I cant hardcode this link in my php code beacause when I (and other users) change profile picture, Link B will not true.
So I want to ask if we can using PHP code to get the Link B that returned from Link A and after that, I will set LinkB to "src" attr to display the newest facebook profile picture ID.
Thanks and I hope you will help me :)
Facebook is using HTTP redirection using Location header so it's pretty simple to get final URL of an image:
$url = 'http://graph.facebook.com/100001225080368/picture';
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HEADER => true,
CURLINFO_HEADER_OUT => true,
CURLOPT_NOBODY => true,
CURLOPT_RETURNTRANSFER => true
));
$headers = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code == 302) {
preg_match('/Location:(.*?)\n/', $headers, $matches);
// NOTE: this will contain URL from `*.fbcdn.net`
$directURL = trim(array_pop($matches));
} else {
// NOTE: Previous code wasn't redirect by Facebook to original image
// Do some fallback...
}