Target specific slide in Soliloquy slider with url - slider

Does anyone have any experience with using a url to target a specific slide in a Soliloquy slider? I am using multiple sliders that I need to link to specific slides of from external pages/sites. The Soliloquy Docs provide this info (soliloquywp.com/docs/dynamically-set-the-starting-slide/) as closest to the solution but, for a php noob like me, the explanation is a bit terse and lacking, my fault, not theirs.
The example given in the docs seems to be a custom filter for a specific slide in a specific slider. I need to target slides in multiple sliders with urls. I guess I need help understanding the filter's function. I have commented out what I think each part does. Maybe someone could show me where I'm wrong?
//OP: I don't understand, what ids/slides are represented by the 10 and 2 values in these parameters. Where do I find these?
add_filter( 'soliloquy_pre_data', 'tgm_soliloquy_dynamic_starting_slide', 10, 2 );
function tgm_soliloquy_dynamic_starting_slide( $data, $slider_id ) {
// If the proper $_GET parameter is not set or is not the proper slider ID, do nothing.
//OP: Is the 'sol_slide' parameter for ALL soliloquy sliders in my site or is it the name in the Dashboard given when constructing the slider?
if ( empty( $_GET['sol_slide'] ) ) {
return $data;
}
// Change this if you want to target a specific slider ID, or remove altogether if you want this for all sliders.
//OP: I believe to target ALL sliders in my site I should comment this out. Right?
if ( 51064 !== $slider_id ) {
return $data;
}
// Set the slide number as a config property. Also preventing randomizing slides.
$data['config']['start'] = absint( $_GET['sol_slide'] );
$data['config']['random'] = 0;
// Optionally prevent autostarting the slider. Uncomment if you want that.
//$data['config']['auto'] = 0;
return $data;
}
Basically, I guess I am asking for a little help with implementing this filter to target any slide in any slider with a url. Slim odds, but I'm dead in the water! Big thanks to anyone who can shed some light on this for me.

Complete, correctly functioning answer is here provided the plugin author, of course, duh: http://soliloquywp.com/support/topic/a-way-to-link-directly-to-a-specific-slide/
The value "sol_slide" is generic to any slider created with the plugin. Just put the custom filter provided in the example into your, hopefully, child-theme's functions.php, and construct your urls targeting specific slides like so: http://mywebsite.com/specific-product-page-with-slider/?sol_slide=3. Slide numbering is based on zero so 1 = 2 etc. Works like a charm.

Related

Keyboard shortcuts on Flutter web

I'm adding keyboard shortcuts to a Flutter web application.
I have a form within a custom FocusableActionDetector where the shortcut has form like this:
SingleActivator(LogicalKeyboardKey.digit2)
and action is like:
CustomActivateIntent: CallbackAction<CustomActivateIntent>(
onInvoke: (intent) { provider.value = "2"; },)
In the same form I have a couple of numeric TextFormFields. To permit writing the character "2" I have to put these text fields inside some new FocusableActionDetector, otherwise the previous detector catches the command and the text field loses the "2" character, and this is already quite weird... Moreover, after writing in any of the text fields the form focus detector doesn't work anymore.
I think this could be related to the focus system, which is yet not that clear to me.
Can anyone help find a clean solution?
I found a workaround: the FocusableActionDetector is now preceded by an if statement. The code looks like the following:
// I extract the form to a widget to make it clearer
var searchWidget = SearchWidget();
child: textEditingInProgress
? searchWidget
: FocusableActionDetector(
child: searchWidget,
...,
),
The textEditingInProgress bool is a field in a provider and is controlled by the FocusNodes belonging to the TextControllers.
Still this is not a perfect solution, in particular I'd like to understand why the previous approach was not working.

How can I change the module position from code in Prestashop 1.7?

I learn actually Module Programming in Prestashop 1.7.... hard work but really good.
So, when I install my first module,
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if ( !parent::install() or
!$this->registerHook('displayTop') or
!$this->registerHook('header') or
!$this->registerHook('backOfficeHeader') )
return false;
return true;
}
the position will automatically set at the end of the hook displayTop.
Now, what must I do to set it on the first place ?
I have read it will works with the function "updatePosition", unfortunately I find only tips of 2012 and 2-3 years earlyier.
The developer docs have a hint here,
https://devdocs.prestashop.com/1.7/development/components/position-updater/
but I don't understand how to implant it into your module.
Does anyone have the time to explain me how the desired order is laid out by the code?
And does this happen in the install method or from where?
Go to your admin panel, in "**Design**" then "**Position**".
Look for '**displayTop**' in the "**Search for hook**" search bar at your top-right.
Then drag and drop your module which is in the last row and place it in the first row.
Change module's position in the hook list

Google plus share button, current URL instead of Specified URL?

If clarification is needed, please let me know. If it can't be done, please let me know this as well. I am desperately trying to figure this out still
I was following Google's Dev guide to the Share button at the following site:
https://developers.google.com/+/web/share/
and I can not seem to figure out how, if it's even possible, to use a custom icon AND use the current URL instead of having to specify a URL.
I found this section of their site that specifies an anchor tag address:
"https://plus.google.com/share?url={URL}"
This would allow me to use a custom icon (and the only way I can use a custom icon as far as I can tell) and a few other custom parameters as well. But it looks like this method requires a specified URL and, as far as I can tell, provides no method to dynamically create the link depending on the current page.
If I use the code generator at the top, it will use the current page, but it calls on a Google hosted Java Script and in addition, it is a hover link that pops up when I hover over the icon. And of course, I also can't use a custom icon with the generator either.
I've been Googling every search term I could think of and searching this site as well and I haven't been able to find anyone else asking this question as of yet. I figured after about 20-30 minutes of searching that I wasn't going to find my answer via searching, so i apologize if this has been answered.
Just some background on my experience to give an idea of where I sit: I have a decent grasp of the workings of HTML and CSS. Javascript, however, I understand very very basic theory and that's about it. I definitely intend to learn, however, as it will prove a very valuable skill.
Thank you very much!!
I think I know what needs to be done, but...I don't know how to do it (or if it would even work) :|
my share link needs to link to a script that looks at the current page's URL, and then takes that information, and creates a dynamic link from it that will take the user to the following link: https://plus.google.com/share?url={URL from query will be here}.
I think that might work...it sounds like it would. Any thoughts? If so, any simple scripts around that would do just this?
Double thanks!!
--I finally found something that works, but it uses Javascript and I don't fully understand it, just enough to tweak it. It took me forever to find this, but it works with Google Plus, Facebook, or Twitter! (and I'm sure it will work with any other website that supplies a Share Link that requires a specified URL)
Here it is, I'm still looking for a better solution, but this does exactly what I was looking for:
<a href="javascript:(
function(){
var w=480;var h=380;
var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
window.open('https://plus.google.com/share?url='+encodeURIComponent(location.href)+'
&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y +',
scrollbars=no');
})();" style="background: url(/wp-content/themes/HTML5/images/googleplus.png) no-repeat scroll left center transparent;">
Share to Google+</a>
EDIT! After spending some months learning Javascript, I've built a solution that is much better than that which is provided below. I'll leave my original answer, however, I want to place this better solution at the top.
This solution should work on ANY social media platform that gives you a custom share URL (that is to say, a url that allows you to manually type in an address to share).
Here is how it all works (and if anyone has any suggestions or tweaks that have more experience with JS, please let me know).
I assign variables to the document.URL and document.titleproperties.
I write a named function (I called mine, socialShare) that is set to run via an anonymous function on the window.onloadevent.
The socialShare function assigns variables to the location of my social button's within the HTML. In my case, I used IDs to locate the elements. The purpose of these variables is purely for aesthetics (I use these variables to re-write the the HTML code dynamically, so that when you hover over the share button, it displays the correct URL for sharing the current page you are on)
var fbShare = document.getElementById("fbShare");
var gplusShare = document.getElementById("gplusShare");
twitterShare = document.getElementById("twitterShare");
I then write three separate anonymous functions, one for each social media platform. Each function has two statements. The functions work as follows: the first part is the variable assigned to the location of the HTML element with the ID fbShare. The second part tells it to run the function when that element is clicked; .onclick. The third part is the anonymous function that will run when that element is clicked. The first statement of this function will open a new window; window.open; and in that new window, it will open the URL that is specified by feeding the window.open method parameters. The parameters are as follows (URL,name,specs) where URL is the URL you want to share, name is optional and left blank as seen by the empty set of quotes, and finally specs is where you specify attributes of the window (IE: width and height). The first parameter, the URL: ("https://www.facebook.com/sharer.php?u="+currentURL, currentURL is the global variable that was assigned earlier and will place whatever the current documents URL is, in place of currentURL. The second parameter, the name: "", This is left blank, as it is optional. The third parameter, the specs: "height=368,width=600,left=100,top=100,menubar=0"); These are a comma-seperated list of items. In my case, I've specified a height, width, and the location of the window, as well as disabled the menubar. Finally, the second statement, return false; tells the browser NOT to follow the link inside the HTML code. If this was not specified, then the browswer would follow the URL in the HTML, AND open a new window. For more information on the window.open method, please see the link at the bottom of this new answer.
fbShare.onclick = function() {
window.open("https://www.facebook.com/sharer.php?u="+currentURL,"","height=368,width=600,left=100,top=100,menubar=0");
return false;
}
gplusShare.onclick = function() {
window.open("https://plus.google.com/share?url="+currentURL,"","height=550,width=525,left=100,top=100,menubar=0");
return false;
}
twitterShare.onclick = function() {
window.open("https://twitter.com/share?url="+currentURL+"&text="+currentTitle,"","height=260,width=500,left=100,top=100,menubar=0");
return false;
}
And finally, I modify the HTML href elements of each social media button so that when the user hovers over the share buttons, they see the correct Share URL displayed in their browsers status bar. The first part of this statement grabs the element id, fbShare and the second part tells it to set an attribute, .setAttribute. Then we pass in the attribute name that we want to change, ("href", in this case, and then we pass in what we would like the new attribute value to be, "http://www.facebook.com/sharer.php?u="+currentURL); currentURL is the same here, as earlier. It is the variable that holds the value for whatever the current page's URL is.
fbShare.setAttribute("href","http://www.facebook.com/sharer.php?u="+currentURL);
gplusShare.setAttribute("href","https://plus.google.com/share?url="+currentURL);
twitterShare.setAttribute("href","https://twitter.com/share?url="+currentURL+"&text="+currentTitle);
That's about all there is to it! I hope I wrote this well and I hope it is relatively easy to follow. If any pros out there have any suggestions, please feel free to toss in and give your advice! :)
My JS file
http://jrltest.host-ed.me/_js/share.js
Link to information on the window.open method at w3schools.com
http://www.w3schools.com/jsref/met_win_open.asp
Link to information on the .setattribute method at w3schools.com
http://www.w3schools.com/jsref/met_element_setattribute.asp
OLD ANSWER: I figured I'd add this as an answer. It does the trick and solves the exact problem that I had. The URL after 'window.open' would be the social media's Share Link (in the case of the example, it's google plus' Share Link. There are a few variables that can be either modified or removed. Anyone that's good with scripting could probably create a PHP version (which I would LOVE) or modify it to better suite their needs. At any rate, I hope this will help someone out!
<a href="javascript:(
function(){
var w=480;var h=380;
var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
window.open('https://plus.google.com/share?url='+encodeURIComponent(location.href)+'
&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',
scrollbars=no');
})();" style="background: url(/wp-content/themes/HTML5/images/googleplus.png) no-repeat scroll left center transparent;">
Share to Google+</a>
Native Window Open function its not a good idea, browsers like Mozilla and Chrome block pop up. I think its better use a plugin to open a new windows with the share url, like jquery popup plugin. Work very fine for me and browser cant block it.
Copy an paste into a new js file like original name: 'jquery.popup.js'
jQuery.fn.popup = function(options) {
var defaults = {
width: screen.width/2,
height: screen.height/2,
titlebar: false,
status: false,
resizable: true,
toolbar: false,
scrollbars: true,
menubar: false
};
var options = jQuery.extend(defaults, options);
Boolean.prototype.setProperty = function() {
if (this == true) { return "yes"; } else { return "no"; }
};
jQuery(this).click( function() {
var target = this.target;
var href = this.href;
var posY = (parseInt(screen.height/2)) - (parseInt(options.height/2));
var posX = (parseInt(screen.width/2)) - (parseInt(options.width/2));
var win = window.open(href, target, 'titlebar=' + options.titlebar.setProperty() + ', screenX='+ posX +', screenY='+ posY +', left='+ posX +', top='+ posY +', status=' + options.status.setProperty() + ', resizable=' + options.resizable.setProperty() + ', toolbar=' + options.toolbar.setProperty() + ', scrollbars=' + options.scrollbars.setProperty() + ', menubar=' + options.menubar.setProperty() + ', width='+ options.width +', height='+ options.height);
win.focus();
return false;
});
return this;
};
USAGE:
<script src="jquery.last.js"></script>
<script src="jquery.popup.js"></script>
<script>
jQuery(function(){
//simple load
jQuery(".popupLink").popup({ width: 640, height: 480 });
});
</script>
<a class='popupLink' href="https://www.facebook.com/share.php?u=<?php echo URL;?>">Share Facebook</a>
ALSO YOU CAN PASS OPTIONS LIKE THE PLUGIN EXAMPLE OPTIONS
<script>
jQuery(".popupLink").popup({ width: 640, height: 480, resizable: false, menubar: true });
</script>
The author website dont exist any more. This are the information that comes with the plugin comments
/*
* jQuery popup v1 - A jQuery popup plugin.
* By Jordan Thomas - http://labs.wondergroup.com
* Licensed under the do whatever you want to license.
* If you like, keep this message intact so
* someone else can find the origin.
*/
You can also use PHP to resize the window but here is the PHP version... Have fun :)
See Also: PHP - Getting Current URL
<?
echo '<a href="https://plus.google.com/share?url='.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI].'"
target="_blank"><img src="images/google-custom-icon.png"></a>';
?>

Need to lighten a color within the variables passed in a LESS mixin

I am currently updating the bootstrap source less files for a project and I have to modify the hover state for the buttons. The end goal is something along these lines:
.btn-primary {
.buttonBackground(#btnPrimaryBackgroundHighlight, #btnPrimaryBackground);
&.hover {
.buttonBackground( lighten(#btnPrimaryBackgroundHighlight, %20), lighten(#btnPrimaryBackground, %20));
}
}
However, that returns a compile error. Any thoughts on this issue? I'm sure it's something simple, but I'm at a loss. Thanks in advance.
P.S. - I will also be using the :hover pseudo-class, but for sake of example I'm using a simple class.
Put the percent sign after the number (20% instead of %20)

Dojo dnd (drag and drop) 1.7.2 - How to maintain a separate (non-dojo-dnd) list?

I'm using Dojo dnd version 1.7.2 and it's generally working really well. I'm happy.
My app maintains many arrays of items, and as the user drags and drops items around, I need to ensure that my arrays are updated to reflect the contents the user is seeing.
In order to accomplish this, I think I need to run some code around the time of Source.onDndDrop
If I use dojo.connect to set up a handler on my Source for onDndDrop or onDrop, my code seems to get called too late. That is, the source that's passed to the handler doesn't actually have the item in it any more.
This is a problem because I want to call source.getItem(nodes[0].id) to get at the actual data that's being dragged around so I can find it in my arrays and update those arrays to reflect the change the user is making.
Perhaps I'm going about this wrong; and there's a better way?
Ok, I found a good way to do this. A hint was found in this answer to a different question:
https://stackoverflow.com/a/1635554/573110
My successful sequence of calls is basically:
var source = new dojo.dnd.Source( element, creationParams );
var dropHandler = function(source,nodes,copy){
var o = source.getItem(nodes[0].id); // 0 is cool here because singular:true.
// party on o.data ...
this.oldDrop(source,nodes,copy);
}
source.oldDrop = source.onDrop;
source.onDrop = dropHandler;
This ensures that the new implementation of onDrop (dropHandler) is called right before the previously installed one.
Kind'a shooting a blank i guess, there are a few different implementations of the dndSource. But there are a some things one needs to know about the events / checkfunctions that are called during the mouseover / dnddrop.
One approach would be to setup checkAcceptance(source, nodes) for any target you may have. Then keep a reference of the nodes currently dragged. Gets tricky though, with multiple containers that has dynamic contents.
Setup your Source, whilst overriding the checkAcceptance and use a known, (perhaps global) variable to keep track.
var lastReference = null;
var target = dojo.dnd.Source(node, {
checkAcceptance(source, nodes) : function() {
// this is called when 'nodes' are attempted dropped - on mouseover
lastReference = source.getItem(nodes[0].id)
// returning boolean here will either green-light or deny your drop
// use fallback (default) behavior like so:
return this.inhertied(arguments);
}
});
Best approach might just be like this - you get both target and source plus nodes at hand, however you need to find out which is the right stack to look for the node in. I believe it is published at same time as the event (onDrop) youre allready using:
dojo.subscribe("/dnd/drop", function(source, nodes, copy, target) {
// figure out your source container id and target dropzone id
// do stuff with nodes
var itemId = nodes[0].id
}
Available mechanics/topics through dojo.subscribe and events are listed here
http://dojotoolkit.org/reference-guide/1.7/dojo/dnd.html#manager