I wanted to implement infinite scrolling in my magento website so I installed the Strategery - InfiniteScroll extension but it is not working, first I thought it is because I still have pagination, but even after removing the paging toolbar it is not working.
I removed those toolbar divs
<div class="toolbar-top">
<?php echo $this->getToolbarHtml() ?>
</div>
from top and bottom.
Can you please help me to configure Strategery - InfiniteScroll extension?
From https://github.com/Strategery-Inc/Magento-InfiniteScroll/wiki/Installation-under-a-different-package---theme:
If you copy the 'infinitescroll' folder on your webroot, the files
will end up under the default theme. This should be ok in most
installations because Magento falls back to the default theme when it
can find files in the custom themes. The rest of this article covers
the scenario where the plugin isn't loaded correctly from the default
package/theme.
The first thing you should do is move them to the package/theme you're
using, just to be sure they'll be loaded.
Browse the repository to see where the files are located. Those that are inside the 'app/design/frontend/default/default' should be
moved to your package/theme: 'app/design/frontend/package/theme'.
Visit the following url: http://www.yourwebsite.com/infinitescroll2/js and make sure there's
some Javascript being printed. If you get a 404 then the module is not
loaded properly. If its blank or you get an exception then the module
probably has trouble finding the layout or template files.
Once the URL above returns javascript, visit a page in your catalog and view its source. Make sure you can find the following
string within the source: "infinitescroll/js" - it should exist as
part of the URL for a SCRIPT tag. If you can't find it then you have a
compatibility problem with the layout file (which in the repository is
located at
app/design/frontend/default/default/layout/strategery-infinitescroll.xml).
If the string exists however then the plugin is loaded and configured properly.
Finally, once you know the plugin is being loaded, you will have to adjust the options under System -> Configuration -> Catalog ->
Infinite Scroll in order to configure InfiniteScroll options properly.
You will find two types of selectors. The first one is the container, by default called "category-products", which "contains" all
the items. category-products
Then you will find another selector called "products-grid" which is
the item selector. item
This two selectors are the ones you must enter in the Infinite Scroll
configuration under Content and Items.category-products
Next: next
You can get the code by doing a second click on the screen and picking
"Inspect element" in any modern browser.
For this extension to work with any theme, the theme must have a
container div, like category-products and also a item div like
products-grid.
Also the theme must have the pager active, otherwise the extension
wont work because of the lack of some selectors.
For more information on how to configure the options follow this link:
http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/
OR
If problem not solved then
After the installation
Add the following in layout.xml:
strategery/infinitescroll/init.phtml
Copy from app/design/frontend/base/default/template/strategery path to the same path in your theme
Copy from skin/frontend/base/default/js/infinitescroll path to the same path in your skin-theme
Make sure that the /js/jquery/infinitescroll path exist and have four *.js files inside
Configure plugin:
always set Yes on Include jQuery field
always view that your product-list div class is same as in Content field. In default theme is ".category-products" class (with the dot is
a first sign in class name)
always set No on Hide Toolbar field
Of cource you should flash all possible cache :) If not working - do this:
On the page set grid mode manually an you can see "mode=grid" in url. Thats all, guys :)
Cause of some extensions that modify the output of the system in JSON and not in HTML - I solved it this way:
in JQuery-ias.js, on line 340
return $.get(loadEvent.url, null, $.proxy(function(data) {
$itemContainer = $(this.itemsContainerSelector, data).eq(0);
if (0 === $itemContainer.length) {
$itemContainer = $(data).filter(this.itemsContainerSelector).eq(0);
}
if ($itemContainer) {
$itemContainer.find(this.itemSelector).each(function() {
items.push(this);
});
}
self.fire('loaded', [data, items]);
if (callback) {
timeDiff = +new Date() - timeStart;
if (timeDiff < delay) {
setTimeout(function() {
callback.call(self, data, items);
}, delay - timeDiff);
} else {
callback.call(self, data, items);
}
}
}, self), 'html');
I've changed it like this:
return $.get(loadEvent.url, null, $.proxy(function(data) {
data = data['maincontent']; // HERE TO CATCH THE RIGHT HTML CONTENT
$itemContainer = $(this.itemsContainerSelector, data).eq(0);
if (0 === $itemContainer.length) {
$itemContainer = $(data).filter(this.itemsContainerSelector).eq(0);
}
if ($itemContainer) {
$itemContainer.find(this.itemSelector).each(function() {
items.push(this);
});
}
self.fire('loaded', [data, items]);
if (callback) {
timeDiff = +new Date() - timeStart;
if (timeDiff < delay) {
setTimeout(function() {
callback.call(self, data, items);
}, delay - timeDiff);
} else {
callback.call(self, data, items);
}
}
}, self), 'json'); // I've changed html by JSon
Related
I'm trying to migrate a typo3 7.6.32 installation to 8.7.24. After updating all extensions to the most recent versions and having the basic page setup and working, the ke_search extensions breaks on one specific page only.
Actual Error Message:
Argument 1 passed to TYPO3\CMS\Fluid\View\StandaloneView::setTemplateRootPaths() must be of the type array, null given, called in /var/www/web18/htdocs/relaunch2016_t3v8/typo3conf/ext/ke_search/pi1/class.tx_kesearch_pi1.php on line 95
TypeError thrown in file
/var/www/web18/htdocs/typo3_src-8.7.24/typo3/sysext/fluid/Classes/View/StandaloneView.php in line 178.
16 TYPO3\CMS\Fluid\View\StandaloneView::setTemplateRootPaths(NULL)
/var/www/web18/htdocs/relaunch2016_t3v8/typo3conf/ext/ke_search/pi1/class.tx_kesearch_pi1.php:
00093: {
00094: $this->searchFormView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
00095: $this->searchFormView->setTemplateRootPaths($this->conf['templateRootPaths']);
00096: $this->searchFormView->setPartialRootPaths($this->conf['partialRootPaths']);
00097: $this->searchFormView->setLayoutRootPaths($this->conf['layoutRootPaths']);
15 tx_kesearch_pi1::initFluidTemplate()
/var/www/web18/htdocs/relaunch2016_t3v8/typo3conf/ext/ke_search/pi1/class.tx_kesearch_pi1.php:
00067:
00068: // init template for pi1
00069: $this->initFluidTemplate();
00070:
00071: // hook for initials
This goes on for a few more lines but I believe the problem lies in this part.
I've tried this solution but to no avail. As far as I can tell (using the Typo3 Object Browser) the entire config is not being loaded for ke_search at all.
This is (part of) the original typoscript for 7.6:
plugin.tx_kesearch_pi1 {
templateRootPath = fileadmin/fluidtpl/_kesearch/Templates/
partialRootPath = fileadmin/fluidtpl/_kesearch/Partials/
layoutRootPath = fileadmin/fluidtpl/_kesearch/Layouts/
}
plugin.tx_kesearch_pi2 {
templateRootPath = fileadmin/fluidtpl/_kesearch/Templates/
partialRootPath = fileadmin/fluidtpl/_kesearch/Partials/
layoutRootPath = fileadmin/fluidtpl/_kesearch/Layouts/
}
Using the solution from the previously mentioned answer:
plugin.tx_kesearch_pi1 {
templateRootPaths {
5 = EXT:ke_search/Resources/Private/Templates/
}
partialRootPaths {
5 = EXT:ke_search/Resources/Private/Partials/
}
layoutRootPaths {
5 = EXT:ke_search/Resources/Private/Layouts/
}
}
plugin.tx_kesearch_pi2 {
templateRootPaths {
5 = EXT:ke_search/Resources/Private/Templates/
}
partialRootPaths{
5 = EXT:ke_search/Resources/Private/Partials/
}
layoutRootPaths {
5 = EXT:ke_search/Resources/Private/Layouts/
}
}
I also tried adding the previously used templates as a fallback but it didn't seem to be recognized at all. I also cleared the cache after every step but nothing changed, still the same error.
I was prepared having to change the old template files to a certain degree but at this point I can't even get the default templates to work.
Have you shown in the Template Backend Module in the Typoscript-Object-Browser what TYPO3 has calculated for this page? You must have a similiar output like in the screenshot: [Screenshot of TYPO3 Object Browser] [1]: https://i.stack.imgur.com/UZ4es.jpg
I found the mistake: I had another typoscript somewhere down the tree that had overridden the templateRootPath, partialRootPath and layoutRootPath settings. After removing this culprit, everything worked as intended.
I've created a module for Joomla that fetches some data from a database and creates a table with it. I added JPagination to my module and I got the footer buttons to show and everything.
public function addPagination($params)
{
$count = $params->get("count");
$multiPage = $params->get("multiple_pages");
//Add controls for changing pages
if($multiPage)
{
jimport('joomla.html.pagination');
$limitStart = 0;
$pagination = new JPagination(count($this->vacanciesRows) , $limitStart, $count);
echo $pagination->getListFooter();
}
}
but when I click some of the pages (all except the first one) I'm getting error 404. I'm sure I've missed something but I have very little to none experience with Joomla. I'll include pastebins with my helper.php and my mod_xxx_xxx.php
A module can't have a pagination. It has no own URL. Only components have that. If you check the links your module creates, you'll notice that they are invalid. You can try to do Ajax magic but then you need a component providing the data.
In Joomla only components can react to incoming URLs directly.
I was going to update the ecommerce plugin (Shopp) on my wordpress site and it asked me to deactivate it. once I did that I lost the entire site.
I am trying to activate the plugin through the php files, but not sure what I am doing and would like some help.
Does anyone know how I can activate the Shopp plugin (or any plugin for that matter) on my site through the php files?
This is the code I'm using to get the string:
$unserialized = unserialize('a:14:{i:0;s:19:"akismet/akismet.php";i:1;s:37:"breadcrumbs-plus/breadcrumbs-plus.php";i:2;s:35:"googleanalytics/googleanalytics.php";i:3;s:45:"grunion-contact-form/grunion-contact-form.php";i:4;s:43:"image-caption-links/image-caption-links.php";i:5;s:29:"image-widget/image-widget.php";i:6;s:13:"rate/rate.php";i:7;s:33:"restore-jquery/restore-jquery.php";i:8;s:41:"shopp-cache-helper/shopp-cache-helper.php";i:9;s:47:"shopp-default-breadcrumb-extender-sdbe/sdbe.php";i:10;s:33:"shopp-improved/shopp-improved.php";i:11;s:19:"shuffle/shuffle.php";i:12;s:19:"vslider/vslider.php";i:13;s:41:"wordpress-importer/wordpress-importer.php";}');
array_push($unserialized, 'shopp/shopp.php');
$serialized = serialize($unserialize);
echo $serialized;
The active plugins are not stored in a PHP file. It's stored in the database. Open the wp_options table in the database. Look for a row in which the value of the option_name field is active_plugins. In this row, look for the value of option_value. You'll see a serialized string containing the information of the active plugins.
Now, it might be a little bit confusing to edit the string straight away especially if you're not familiar how serialized strings are formatted. So, I suggest you copy the string and use PHP unserialize() function on it, which will then return an array. After that, use array_push() to add another element in which the value is the path to the plugins file (e.g. "akismet/akismet.php", in your case it might be "shopp/shopp.php"). Once you've add another element, use serialize() and copy the returned string and replace the old serialized string in the database.
$unserialized = unserialize('...');
array_push($unserialized, 'shopp/shopp.php');
$serialized = serialize($unserialized);
echo $serialized; // Copy this output back into the database
There are details on this site about how to programmatically activate and deactivate a plugin. Here is a snippet:
function toggle_plugin() {
// Full path to WordPress from the root
$wordpress_path = '/full/path/to/wordpress/';
// Absolute path to plugins dir
$plugin_path = $wordpress_path.'wp-content/plugins/';
// Absolute path to your specific plugin
$my_plugin = $plugin_path.'my_plugin/my_plugin.php';
// Check to see if plugin is already active
if(is_plugin_active($my_plugin)) {
// Deactivate plugin
// Note that deactivate_plugins() will also take an
// array of plugin paths as a parameter instead of
// just a single string.
deactivate_plugins($my_plugin);
}
else {
// Activate plugin
activate_plugin($my_plugin);
}
}
For everyone who has a plugin acting weird
The easiest way to regain access to your site when being locked out after deactivating, activating, installing, updating a plugin is:
Go to your webhost adminpanel (Cpanel, DirectAdmin)
Go to Files (Filemanager)
Go to //wp-content/ and rename your "plugins" folder to something else for instance "plugins_off"
Go to your WP-admin. You will have access again but no plugins visible.
Go back to your webhost adminpanel and rename "plugins_off" back to "plugins".
Now your plugins will all be listed again in WP-admin, but all deactivated.
Take it from there.
There is no need to add PHP code.
Like RST wrote: No need for coding to restore site that crashed after you deactivate a plugin. There's a good reason the site crashed because other plugins depended on that deactivated plugin (like WooCommerce).
The easiest way to restore the site and gain access to WP admin is simply to rename the plugins folder, refresh the page, go back and rename the folder back to "plugins" then hit refresh again. All plugins will be back as before only they are all deactivated. Now all you need to do is to activate them again. Do it one by one to be sure nothing else crashes.
Here is working code
(just uncomment "activate" line):
function MY_toggle_plugins() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$temp_files1 = glob(WP_PLUGIN_DIR.'/*');
$activated=array();
$already_active=array();
foreach($temp_files1 as $file1){
if(is_dir($file1)) {
$temp_files2 = glob($file1 . '/*');
foreach($temp_files2 as $file2){
if(is_file($file2) && stripos(file_get_contents($file2),'Plugin Name:')!==false) {
$plugin_name_full=basename(dirname($file2)).'/'.basename($file2);
if(is_plugin_active($plugin_name_full)) {
array_push($already_active, $plugin_name_full);
//deactivate_plugins($plugin_name_full);
}
else{
array_push($activated, $plugin_name_full);
//activate_plugin($plugin_name_full);
}
}
}
}
}
echo 'You have activated these plugins:<br/><br/>'.serialize($activated).'<br/><br/>These were already active:<br/><br/>'.serialize($already_active); exit;
}
//execute
MY_toggle_plugins();
Is is possible to display (via php) the main menu of a Drupal 6.20 site in a WordPress theme template file located in a subdirectory on the same domain?
Right now, I'm displaying the menu by copying the static html from the Drupal site and adding it to header.php in the WordPress template in the site located in mydomain.com/blog/. But of course that's not going to work when another menu item is added to the Drupal site, or the Drupal menu is changed in any way.
So is there a Drupal php function that will pull the menu into the WP file?
Failing that, is there a way with php to parse a Drupal page for the html of the menu (yes, this would be ugly) and display it in WP?
The first part of the challenge is to output only the menu, with as little (or none) of the surrounding HTML as possible, so you have as little work to do in parsing the HTML as possible.
The second part is to take that output from Drupal and actually display it on your WordPress site.
You could add the Drupal database as a secondary database in WordPress using the a new instance of the $wpdb object, write the query to get the right content from the tables, and format the results. That could work, but might be overkill.
An alternative workable option may be to use JSON to format the output of the primary links, using the drupal_json function in Drupal, then consume the JSON feed in Wordpress.
I'm assuming:
you have admin access to login to the Drupal site, which you'll need to create nodes, and clear the theme cache
you want to output the Primary Links menu, which 90%+ of Drupal sites use. This is probably true, but it is possible your site uses custom menus. If so, this is still possible, you'd just write slightly different code in step 3.
The steps would be:
Create a Drupal node (you can call it anything, it's just a placeholder)
Get the node id of your dummy page (ie., node/234). From the node id, create a one-off page template in your Drupal site's themes folder. It should be called page-node-xxxx.tpl.php, with xxxx being your node id
Add this code to page-node-xxxx.tpl.php:
<?php
drupal_json(menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links')));
?>
This will create a JSON feed of your menu items.
Clear the theme cache of your Drupal site by visiting http://yoursite.com/admin/build/themes and visit http://yoursite.com/node/xxxx to see the raw JSON feed.
You should now be able to use a jQuery method like $.getJSON or $.ajax in your Wordpress theme to consume and display the JSON feed, or possibly use json_decode and curl to output your array as HTML.
A good thing about Drupal's drupal_json function is that it already sends the correct JSON headers, so now all you have to do is write the jQuery or PHP that does what you need.
I'm assumed you are more of a Wordpress specialist and have a working knowledge of Drupal but maybe not a lot of familiarity with its inner workings. So, sorry if it seemed too basic (or not basic enough :).
The Drupal theming engine is very modular - you may be able to make an appropriate PHP call into Drupal to get just the menu rendered, then emit that HTML as a part of your WordPress page.
g_thom's answer is very good and if you wish to create a very simple module to output the main navigation you can write something like this:
<?php
function getmenus_help($path, $arg) {
// implementing the help hook ... well, not doing anything with it just now actually
}
function getmenus_all() {
$page_content = '';
$page_content = json_encode(menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links')));
// fill $page_content with the menu html
print $page_content;
return NULL;
}
function getmenus_menu() {
$items = array();
$items['getmenus'] = array(
'title' => 'Get Menus',
'page callback' => 'getmenus_all',
'access arguments' => array('access getmenus'),
'type' => MENU_CALLBACK,
);
return $items;
}
// permissions
function getmenus_perm() {
return array('access getmenus');
}
In your PHP code you can then write something like:
function primary_links() {
$primary_links = file_get_contents(SITE_URL . '/getmenus');
$primary_links = json_decode($primary_links);
$primary_links = (array)$primary_links;
$i = 0;
$last = count($primary_links);
$output = '';
foreach ($primary_links as $pm) {
$href = $pm->href;
if (strpos($pm->href, 'http://') === FALSE) {
if ($pm->href == '<front>') {
$href = SITE_URL . '/';
} else {
$href = SITE_URL . '/' . $pm->href;
}
}
$output .= '
<li>
'.$pm->title.'</li>';
$i++;
}
return $output;
}
I hope this helps!
PS: Make sure you update the module's permissions to allow anonymous users to have access to the path you set in your module - otherwise you will get a 403 Permission Denied.
I have been trying to load fivestar module and show the rating widget of the selected node in an external php file. I have gotten the rating widget displayed on the page but it only displays degraded version of the widget (non-JavaScript, dropdown widget and "Rate" button) I looked into the source code of the page but the javascript for fivestar module was not loaded. I have tried to load javascript using following functions but had no luck:
fivestar_add_js();
$path = drupal_get_path('module','fivestar');
drupal_add_js($path.'/js/fivestar.js', 'inline', 'footer');
The following is the code in the php file:
//require the bootstrap include
require_once 'includes/bootstrap.inc';
//Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
fivestar_add_css();
// I have used one of the following two functions one at a time to test.
fivestar_add_js();
$path = drupal_get_path('module','fivestar');
drupal_add_js($path.'/js/fivestar.js', 'inline', 'footer');
$book = $_GET["book"];
$chap = $_GET["chap"];
$prob = $_GET["prob"];
$string = $book.'/'.$chap.'/'.$prob;
$query = "SELECT ctcr.nid FROM content_type_comments_ratings AS ctcr WHERE ctcr.field_problem_value = '".$string."'";
$result=db_query($query);
$row = db_fetch_array($result);
if(isset($row['nid']))
{
$nid = $row['nid'];
node_load(FALSE, NULL, TRUE);
$fivestar = node_load($nid, NULL, TRUE);
if (function_exists('fivestar_widget_form')) print fivestar_widget_form($fivestar);
}
If you could give me a hint or direct me to some reading on the web, I would appreciate it. Thank you very much in advance.
By doing all this on an 'external' page/file, you circumvent the Drupal theming system - drupal_add_js() (and fivestar_add_js(), as it is just using that in the end) do not output the script tags themselves, but simply ensure that they will be included in the $scripts variable in page.tpl.php, which is then responsible to print that variables content. As you do not go through the page template, you get no script tags.
You could do a print drupal_get_js(); in your external file to output the scripts added via drupal_add_js() as a quick fix, but note that this will output all the default drupal js files as well, which might be more than you need (but might as well contain other scripts needed by fivestar, e.g. jquery). Alternatively, you'll have to create the needed script tags yourself.
As for hints on what to read, it is difficult to point you to something particular, but you might want to read up on the theming system in general.