Configuration of plugins - adobe

I try to use the following plugins in local mode:
s.Util.cookieRead https://marketing.adobe.com/resources/help/en_US/sc/implement/util_cookieread.html
s.Util.cookieWrite https://marketing.adobe.com/resources/help/en_US/sc/implement/util_cookiewrite.html
When I type in console i.e. s.Util.getQueryParam I take back the function which seems that the configuration in file it is allright.
s.Util.getQueryParam
AppMeasurement.a.Util.getQueryParam(c, b, d)
How ever when I go to add the example in plugin function
s.campaign = s.Util.getQueryParam("cid");
when I run my site I can't see anything of this plugin
Also when I use the
getNewRepeat https://marketing.adobe.com/resources/help/en_US/sc/implement/getNewRepeat.html
plugin it always shows me as New visitor.
Is there any special configuration I should make in order to make them to work properly?

// set a session cookie named foo to value 'bar'
s.Util.cookieWrite('foo','bar');
// look for cookie named 'foo' and return value if found, and assign it to prop1
s.prop1 = s.Util.cookieRead('foo');

Related

How to pass signInSuccessUrl dynamically to gitkit identity toolkit's widget

I am trying to pass the signInSuccessUrl parameter dynamically to the widget page as an URL parameter. Unfortunately without success.
According to the gitkit forum (https://groups.google.com/d/msg/google-identity-toolkit/grF6C4CByEk/Dz4l2P-mTOwJ) this should work.
Am I missing something? Thank you.
That's what I tried:
The signin.html page showing the widget is configured like this:
JS Config:
var config = {
apiKey: '...',
idps: ["googleplus"],
//signInSuccessUrl:NOT SPECIFIED CAUSE WE PASS IT VIA URL,
oobActionUrl: '//127.0.0.1:8888/gwt/servlet/gitkit/email',
siteName: 'SN',
};
window.google.identitytoolkit.start(...);
Open browser and show Javascript console of browser
Enter the widget page url in browser:
http://127.0.0.1:8888/signin.html?signInSuccessUrl=127.0.0.1%3A8888%2Fgwt%2Fservlet%2Fgitkit%2Fsignedin%0A&o=dynamic
Continue with sign in...
This will not redirect to signInSuccessUrl but rather produce the error:
Uncaught Error: Configuration signInSuccessUrl is required.Si # gitkit.js:217Ik # gitkit.js:248(anonymous function) # gitkit.js:257(anonymous function) # gitkit.js:152(anonymous function) # gitkit.js:213Fc # gitkit.js:38h.dispatchEvent # gitkit.js:36zi # gitkit.js:210U.onReadyStateChangeEntryPoint_ # gitkit.js:208U.onReadyStateChange_ # gitkit.js:208
NOTE: if I set the signInSuccessUrl param in widget config, like:
signInSuccessUrl:"//127.0.0.1:8888/gwt/servlet/gitkit/signedin?o=hardcoded",
It will work but NOT use the signInSuccessUrl provided in the URL but the hardcoded one, i.e. the 'o' param in this example will not be overriden.
The reason it did not work was related to using the open scheme in oobActionUrl
'//127.0.0.1:8888/gwt/servlet/gitkit/email'
When using 'http://127.0.0.1:8888/gwt/servlet/gitkit/email' it did work.
the signInSuccessUrl in the widget configuration is a required field. You always have to provide it. The signInSuccessUrl parameter in the widget url if provided will override the config value. This makes sense since the signInSuccessUrl query parameter is optional and may not always be provided in the url. Try providing it in the config and then pass it in the url. It should work the way you want it to.

Set return value as environment variable

I would like to set the return value of an auth call (a token) as an environment variable so that other calls can make use of the value and I don't have to change that value manually.
Can Paw already do this easily?
If not, how would I lay out an extension to achieve this?
The best is that you set your OAuth dynamic value in your header field, then copy the value (select the text and hit Cmd + C):
Go to edit your environments and paste the dynamic value (Cmd + V) in a new variable:
Now go back to your header, and start to write the name of the environment variable you just created, it will offer you to use this variable:
You should be good to go now:
If later you need a change in your token, you can go back to the environments and edit it there, all at the same place.

Drupal 6 preprocess function for custom template

I have a custom template file I'm using for a page.
Say the page is www.mydomain.com/hello-world
The content of this page is taken from a template file called hello-world.tpl.php
Now I need to have a variable prepared in advance for that page, so I took a look at how core modules achieve this and tried to implement in the same way, only the variables are always null..
for hello-world.tpl.php I created in my module file a function called:
function template_preprocess_hello_world(&$variables) {
$variables['test'] = "test";
}
As I said $test doesn't get any value on www.mydomain.com/hello-world (I receive NULL when var dumping it)
I spent an hour or so double checking that I don't have any typos or anything like that.
Is what I'm doing worng??
Try renaming the function to mymodulename_preprocess_hello_world(&$variables). Don't forget to clear the cache as well.

Sitecore context in HttpModule

I created simple HttpModule, all what I need is just get is valid Sitecore.Context inside but during processing I see that my Sitecore.Context is some kind of default.
I can get Sitecore user that log in to Sitecore, etc.
How to fix it ?
I assume you have a Sitecore Context, but it is null or set to the wrong site or language.
You can change the context like this:
// switch to the preferred site
Sitecore.Context.SetActiveSite("yourSiteName");
// set the preferred database
Sitecore.Context.Database = Sitecore.Configuration.Factory.GetDatabase("master");
// set the preferred language
Language language = Sitecore.Globalization.Language.Parse("en");
Sitecore.Context.SetLanguage = (language, false);
You probably also want to switch back to the original settings after your processing is done. So it is wise to "save" the original settings in a variable so you can change them back afterwards
Take a look at John West's posts on Sitecore pipelines for some background on how the context is being established.
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/All-About-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
and
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Important-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
The following blog post on creating and running custom pipelines should give you an idea how to implement your own pipeline.
http://adeneys.wordpress.com/2008/08/27/creating-and-running-custom-pipelines-in-sitecore/

Drupal - Getting node id from view to customise link in block

How can I build a block in Drupal which is able to show the node ID of the view page the block is currently sitting on?
I'm using views to build a large chunk of my site, but I need to be able to make "intelligent" blocks in PHP mode which will have dynamic content depending on what the view is displaying.
How can I find the $nid which a view is currently displaying?
Here is a more-robust way of getting the node ID:
<?php
// Check that the current URL is for a specific node:
if(arg(0) == 'node' && is_numeric(arg(1))) {
return arg(1); // Return the NID
}
else { // Whatever it is we're looking at, it's not a node
return NULL; // Return an invalid NID
}
?>
This method works even if you have a custom path for your node with the path and/or pathauto modules.
Just for reference, if you don't turn on the path module, the default URLs that Drupal generates are called "system paths" in the documentation. If you do turn on the path module, you are able to set custom paths which are called "aliases" in the documentation.
Since I always have the path module turned on, one thing that confused me at first was whether it was ever possible for the arg function to return part of an alias rather than part of system path.
As it turns out, the arg function will always return a system path because the arg function is based on $_GET['q']... After a bit of research it seems that $_GET['q'] will always return a system path.
If you want to get the path from the actual page request, you need to use $_REQUEST['q']. If the path module is enabled, $_REQUEST['q'] may return either an alias or a system path.
For a solution, especially one that involves a view argument in the midst of a path like department/%/list, see the blog post Node ID as View Argument from SEO-friendly URL Path.
In the end this snippet did the job - it just stripped the clean URL and reported back the very last argument.
<?php
$refer= $_SERVER ['REQUEST_URI'];
$nid = explode("/", $refer);
$nid = $nid[3];
?>
Given the comment reply, the above was probably reduced to this, using the Drupal arg() function to get a part of the request path:
<?php
$nid = arg(3);
?>
You should considder the panels module. It is a very big module and requires some work before you really can tap into it's potential. So take that into considderation.
You can use it to setup a page containing several views/blocks that can be placed in different regions. It uses a concept called context which can be anything related to what you are viewing. You can use that context to determine which node is being viewed and not only change blocks but also layout. It is also a bit more clean since you can move the PHP code away from admin interface.
On a side note, it's also written by the views author.
There are a couple of ways to go about this:
You can make your blocks with Views and pass the nid in through an argument.
You can manually pass in the nid by accessing the $view object using the code below. It's an array at $view->result. Each row in the view is an object in that array, and the nid is in that object for each one. So you could run a foreach on that and get all of the nid of all rows in the view pretty easily.
The first option is a lot easier, so if that suits your needs I would go with that.
New about Drupal 7: The correct way to get the node id is using the function menu_get_object();
Example:
$node = menu_get_object();
$contentType = node_type_get_name($node);
Drupal 8 has another method. Check this out:
arg() is deprecated

Resources