Magento version 2.3.2 show hide editor not working inside whole admin. When i try to add/update any product or pages and click on show/hide editor button editor does not show and inside console.log it show 404 not found mysite.com/static/adminhtml/Magento/backend/en_US/tinymce.js.
I have tried all related commands but not found where it is calling tinymce.js. In magento 2.3 correct path is static/adminhtml/Magento/backend/en_US/tiny_mce_4/tinymce.min.js
But i have no idea where i need to change this path. Inside require.js have no clue to find out real path.
Any one can help me.
I have tried all related commands
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
I have fixed issue by modify in lib/web/tiny_mce/tiny_mce_src.js
1-Find code near line 10833
tinymce.documentBaseURL = window.location.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
if (!/[\/\\]$/.test(tinymce.documentBaseURL))
tinymce.documentBaseURL += '/';
Replace with
tinymce.documentBaseURL = ADMIN_BASE_URL+"/tiny_mce";
tinymce.baseURL = ADMIN_BASE_URL+"/tiny_mce";
if(IS_MINIFY == 1) tinymce.suffix = '.min'; else tinymce.suffix = '';
2- Find code near line 11391
sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
Replace with
sl.add(tinymce.baseURL + '/langs/' + s.language + tinymce.suffix + '.js');
3- Find code near line 10758
tinymce.ScriptLoader.add(this.urls[n] + '/langs/' + s.language + '.js');
Replace with
tinymce.ScriptLoader.add(this.urls[n] + '/langs/' + s.language + tinymce.suffix + '.js');
Change code in bellow file or override in admin theme:
vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml
4- Find code:
<script>
var BASE_URL = '<?php /* #escapeNotVerified */ echo $block->getUrl('*') ?>';
var FORM_KEY = '<?php /* #escapeNotVerified */ echo $block->getFormKey() ?>';
var require = {
"baseUrl": "<?php /* #escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
};
</script>
`
Replace code with:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
$isMinify = $scopeConfig->getValue('dev/js/minify_files', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
?>
<script>
var BASE_URL = '<?php /* #escapeNotVerified */ echo $block->getUrl('*') ?>';
var FORM_KEY = '<?php /* #escapeNotVerified */ echo $block->getFormKey() ?>';
var ADMIN_BASE_URL = '<?php /* #escapeNotVerified */ echo $block->getViewFileUrl('/') ?>';
var IS_MINIFY = '<?php /* #escapeNotVerified */ echo $isMinify ?>';
var require = {
"baseUrl": "<?php /* #escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
};
</script>
5- Run commands
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
Related
i would like to add numeric pagination (and load the posts dynamically) to this page, called 'page-podcast', where i filter, with Ajax call, my podcast (custom post), using these tags, genre, country and type: https://imgur.com/Qw8JOlC.
In my front end, page-podcast.php, i have this div, where post appears:
<div id="datafetch">Search results will appear here</div>
And in page function.php i added the function that call Ajax
add_action( 'wp_footer', 'ajax_fetch' );
function ajax_fetch() {
?>
<script type="text/javascript">
function fetch(e){
jQuery.ajax({
url: '<?php echo admin_url('admin-ajax.php'); ?>',
type: 'post',
data: { action: 'data_fetch', keyword: keywords},
success: function(data) {
jQuery('#datafetch').html( data );
}
});
}
</script>
The following code is the ajax function (always on function.php):
add_action('wp_ajax_data_fetch' , 'data_fetch');
add_action('wp_ajax_nopriv_data_fetch','data_fetch');
function data_fetch(){
...filter part, omitted, because it has nothing to do with the question...
$the_query = new WP_Query($query_args);
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post(); ?>
<h2><?php the_title();?></h2>
<?php endwhile;
else: ?>
<p class="no-criteria"><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php
wp_reset_postdata();
endif;
die();
}
Someone has some tips/examples/code to share? Because i tried many solution that i find on the web, but nothing works.
Resolved.
So, i have added the number of the pages within the ajax function, before the end of the loop:
<?php if ($numberPages > 1): ?>
<ul>
<?php
for ($i = 1; $i <= $numberPages; $i++) {
echo '<li><a name="page" href="#" class="pagination" value="' . $i . '">'
. $i . '</a></li>';
}
?>
</ul>
$numberPages is equal to:
$the_query = new WP_Query($query_args);
$numberPages = $the_query->max_num_pages;
I create a global variable, call $page, set to 0.
Then i worked on my two event:
$(document).on("click touchend", ".premuto", function (event) {
event.preventDefault();
page = 1;
keywords['page'] = page;
keywords[$(this).attr('name')] = $(this).attr('value');
fetch(this);
});
$(document).on("click touchend", ".pagination", function (event) {
event.preventDefault();
keywords[$(this).attr('name')] = $(this).attr('value');
fetch(this);
});
".premuto" is an element that contain the id i want to pass to ajax (custom taxonomy) and page is set to 1.
".pagination" is the list of post's page number (1,2,...).
Finally, on my ajax function, i get the page number:
$paged = $_POST['keyword']['page'];
and in my wp_query i added:
'posts_per_page' => '2',
'paged' => $paged,
We're having some issues with Magento 2 where we're unable to output the order values in our checkout code. Here's our code:
<!---- Onefeed Tracking Code ---->
<?php
//-------------------------------------------
// GET MAGENTO ORDER VALUES FOR TRACKING CODE
//-------------------------------------------
$orderId = $block->escapeHtml($block->getOrderId());
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($orderId);
$total = $order->getGrandTotal();
?>
<script type="text/javascript" language="javascript">
var of_ssid = 'xxxx';
var cs = '<?php echo $total ?>';
var oi = '<?php echo $orderId; ?>';
var it = 1;
</script>
<script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
<noscript>
<img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=xxxx&cs=<?php echo $total ?>&it=1&oi=<?php echo $orderId; ?>" />
</noscript>
<!---- End Onefeed Tracking Code ---->
Any ideas how we can output the data without having to create a module in Magento 2?
This part of your code is definately working (just checked):
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($orderId);
$total = $order->getGrandTotal();
?>
...
<?php echo $total ?>
Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.
I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:
https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly
The new product gallery in Woocommerce is great, but unfortunately I can't get it to work outside the single product template page.
I'm using ajax to load in products in a container on my front page. The ajax call displays the product page: echo do_shortcode('[product_page id="' . $post_id . '"]');. The markup for the gallery is correct, but the .woocommerce-product-gallery container is marked with opacity: 0; and none of the scripts for the gallery is loaded.
How can I implement the gallery functionality with the ajax call and get it working?
Full ajax call:
JQuery
$('.product-modal-toggle').on('click',function(){
var theId = $(this).data('product-id');
var plagg = $(this).data('plagg');
var outfitEnkeltPlaggContainer = $('.outfit-enkelt-plagg');
var parentOutfit = $(this).closest('.outfit').attr('id');
var outfitDescendantContainer = $('#' + parentOutfit + ' .outfit-enkelt-plagg');
$.post('wp-admin/admin-ajax.php', {
action:'my_get_posts',
post_id: theId
}, function(data) {
console.log(data);
outfitDescendantContainer.html(data);
});
});
PHP
/*
** Get Woocommerce Products with Ajax.
** Display Product inside outfit container
*/
function my_get_posts_return() {
global $post;
$post_id = intval(isset($_POST['post_id']) ? $_POST['post_id'] : 0);
if ($post_id > 0) {
$the_query = new WP_query(array('p' => $post_id, 'post_type' => 'product'));
if ($the_query->have_posts()) {
while ($the_query->have_posts()) : $the_query->the_post();
$product = wc_get_product($post_id);
?>
<button class="close-plagg" type="button" name="close-plagg">
<img src="<?php echo get_template_directory_uri(); ?>/library/images/close.svg" alt="Close plagg">
</button>
<?php
echo do_shortcode('[product_page id="' . $post_id . '"]');
// wc_get_template_part( 'content', 'single-product' );
endwhile;
} else {
echo "There were no posts found";
}
}
wp_die();
}
add_action('wp_ajax_my_get_posts', 'my_get_posts_return');
add_action('wp_ajax_nopriv_my_get_posts', 'my_get_posts_return');
PHP
You have to enqueue the scripts of the gallery on your home page :
add_action( 'wp_enqueue_scripts', function(){
if( is_front_page() ){
wp_enqueue_script('zoom');
wp_enqueue_script('flexslider');
wp_enqueue_script('photoswipe-ui-default');
}
});
JS
In the success function of your $.postyou have to call the script :
$( '.woocommerce-product-gallery', data ).each( function() {
$( this ).wc_product_gallery();
} );
Hope this helps
I am using Gantry 5 template and I want to add php code in the header. I set some variables using php and access them in the script tag. For example
<?php
$id = $user->id;
$name = $user->username;
?>
<script>
var id = '<?php echo $id; ?>';
var name = '<?php echo $name; ?>';
</script>
I want to add the above code in head of Gantry 5 template. In we just add the code in index.php but this mechanism is different in Gantry 5. How this code can be added?
I have the following code for joomla 2.5 ....
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
$id = 474;
$link = JRoute::_($menu->getItem($id)->link);
?>
<script>
$(document).ready(function(){
var $link = $('<a>',{
class: 'all-news-link',
href: <?php echo json_encode( $link ); ?>
});
$('#custom-module .moduletable:nth-child(2) h3').append($link);
});
</script>
But it is not getting menu id 474 but 468 that is home page id. My SEF is also not turned on.
You should be able to just do this:
$link = 'index.php?Itemid=474';
Assuming that the location that you print it on the page is picked up by the system plugin that routes output all will be well.
If that is actually what makes it to the page, then you would want to route it manually:
$link = JRoute::_('index.php?Itemid=474');
The router will handle getting the link for you.