check which node user navigated from websitemap asp.net - sitemap

Here's is the scenario .
I have a Website.Map with the following nodes as part of it .
<siteMapNode title="Self" url="" description="" roles="STF,FAC">
<siteMapNode title="My Schedule" url="" description="~/schedule.aspx" />
<siteMapNode title="My Report" url="" description="~/report.aspx" />
</siteMapNode>
<siteMapNode title="Supervisor" url="" roles="SUP">
<siteMapNode title=" Manage Schedule" url="" description="~/schedule.aspx" />
<siteMapNode title="Send Notification" url="" description="~/notification.aspx" />
</siteMapNode>
In my website, I have an aspx page called schedule.aspx which I would use to list schedule.I could navigate to this page from
a) Self-> My Schedule in website map menu
or
b) Supervisor - > Manage Schedules in website map menu .
1) When I navigate to schedule page from Self - > My Schedule , the schedule page has to show my( user's ) schedule
or
2) When I navigate to schedule page from Supervisor - > Manage Schedule , the schedule page has to show all my subordinates ( those whom User supervises ) schedules.
So in the pageload event of schedule.aspx , I would like to check where the user is coming from whether from Self or from Supervisor.
Is there any way I could achieve this ?

Related

How to add promotional labels on top of images in Magento 2 ?

How can I place a promotional label layer on top of images in Magento 2. The image I am including is from the out of the box Magento 2 theme and it has a text " New Luma Yoga Collection ...." and a button "Shop New Yoga" that was somehow placed on top of the image in the editor .
This is how it looks in the editor
There are various ways on how you can achieve this. One way is to add a HTML element directly into the WYSIWYG editor and mark it up with HTML. This is also how the Luma theme has done this. If you look at your editor, you see the content in small blue below the image. If you switch from WYSIWYG to HTML, you can see the HTML markup of this element:
<span class="content bg-white">
<span class="info">New Luma Yoga Collection</span>
<strong class="title">Get fit and look fab in new seasonal styles</strong>
<span class="action more button">Shop New Yoga</span>
</span>
You can simply use CSS to style this element.
However...
Although this is a very widely uses approach to do such a thing (and it's easy and fast to do so), it's not the most elegant solution. After all, it's not clear from the WYSIWYG-editor that the 'blue link' is actually a special element. If your client starts messing with it, he will break the layout and call you because 'you made the site, so it's your fault'. Trust me, I've been there...
A more elegant solution would be to use widgets. A widget is very simple to create in Magento 2. First you have to create a file called widget.xml in the etc-folder of your module, and put something like this in it:
<?xml version="1.0"?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="example_widget" class="Vendor\Module\Block\Widget\Example">
<label translate="true">Example widget</label>
<description translate="true">This is an example widget</description>
</widget>
</widgets>
Now you can create a Block in the Block-folder of your module:
use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;
class Example extends Template implements BlockInterface
{
/**
* #return string
*/
public function _toHtml()
{
return '<p class="hello">Hello world!</p>';
}
}
Now if you click the widget-button in the WYSIWYG-editor, the widget will be there in the list of widgets to choose from:
Now, if you insert this widget in your WYSIWYG editor, you're sure about the HTML it will output (since that is handled with PHP), and your client cannot 'break it'.
In your scenario you most likely want to add parameters so you can make your widget reusable. This is very simple. Edit your widget.xml:
<widget id="example_widget" class="Vendor\Module\Block\Widget\Example">
<label translate="true">Example widget</label>
<description translate="true">This is an example widget</description>
<parameters>
<parameter name="name" xsi:type="text" visible="true" sort_order="0">
<label translate="true">Name</label>
<description translate="true">Please enter a name</description>
</parameter>
</parameters>
</widget>
And to use it in your Block Class:
public function _toHtml()
{
return '<p class="hello">Hello ' . $this->getName() . '</p>';
}
It's really that simple.
In your specific case I would suggest creating a widget with 4 parameters:
Header
Content
Button Text
Button Link

Change page at XULRunner

At my current project we got a website which is shown of a microcontroller at a monitor. I found XULRunner for displaying the page. It is nice, so I can hide all user panels very easy.
The microcontroller got a controller application too. The controller application gets the url which should be displayed from a server. With firefox I can execute "firefox theUrl" and it opens the browser with that url. If the browser is already running, the page opens at the running firefox.
To get that behavior at XULRunner, my main.xul looks like this:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="display" windowtype="display" title="Display"
onload="init();" hidechrome="true" zlevel="6">
<script type="application/javascript" src="cmdline.js" />
<script><![CDATA[
function init() {
var cmdLine = window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine);
var content = document.getElementById("content");
content.setAttribute("src", cmdLine.getArgument(0));
content.contentWindow.focus();
window.resizeTo(screen.width, screen.height);
}
]]></script>
<hbox flex="1">
<browser id="content" flex="1" disablehistory="false"
src="chrome://commandlineinit/content/default.html" />
</hbox>
</window>
My prefs.js got that content:
pref("toolkit.defaultChromeURI", "chrome://applicationname/content/main.xul");
pref("toolkit.defaultChromeFeatures", "dialog=no, chrome, centerscreen");
pref("toolkit.singletonWindowType", display
And the chrome.manifest:
content applicationname content/
So, now I can open with xulrunner application.ini http://www.myPage.de the page. But when I call it a second, it do nothing.
So I added the commandline handler from that tutorial: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/XULRunner/CommandLine
At the method "observe" at chrome/content/cmdline.js I added
var cmdLine = window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine);
var content = document.getElementById("content");
content.setAttribute("src", cmdLine.getArgument(0));
content.contentWindow.focus();
Now I have 2 problems. At that method, it can't find the element with ID content. So I can't change the url.
The other problem: It calls the observe method only at the first call. I think, the component components/clh.js isn't registert.
What did I wrong?

Magento: Category Lock/Warning or T&C

I wonder if there is a way to add a Warning/Advisory or Terms & Conditions (preferably) to a category or a landing page to warn users about adult content. On the shop I'm working on there is an "Adult Section" Category for Erotic Toys, Lingerie, cosplay, etc. and I need to warn users about such content before they access the section in case they're less than 18.
I've searched the web and only found paid extensions which I cannot afford. Does anyone know how to do this?
I'm using Magento CE 1.7.
Thanks,
EDIT:
Ok, so I've been trying to figure out how to do this and I just figured that the best way to do it would be to just create a Category Landing Page and adding a java script for T&C redirect to the page I want it to.
This is the code I would use for the Category Landing Page with blank content would be this.
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_collectionSize = $_categories->count() ?>
<div>
<?php $i=0; foreach ($_categories as $_category): ?>
<?php
$layer = Mage::getSingleton(‘catalog/layer’);
$layer->setCurrentCategory(Mage::getModel(‘catalog/category’)->load($_category->getId()));
$helper = Mage::helper(‘catalog/category’);
?>
Then I found a code snippet that would redirect the user to a page of my liking after clicking accept but I'm not sure how to implement it and/or if this is the best choice. Here's the code.
<form action="url-to-go-to" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
Now I was thinking that it would be best to just create a simple CMS page and point the category on the top menu to that page and once they have agreed and clicked on continue, they could be taken to the actual category by simply pointing the 'onclick' to the URL of the actual category.
Not sure if this is the best way but it's the only way I could come up. The other way I thought of would've required me to take the "agreements" during checkout that already comes with magento and make an extension that would allow me to place it on any page and call the "Agreement ID" from the Sales/Terms and Conditions tab but I don't know how to actually do that, it was just a thought.
If anyone has a better solution, I'd be happy to hear it.
I would add some sort of JavaScript that shows a div over the top of the whole page, that will create a session cookie when you accept to watch the category. Otherwise, make a back() in the history navigation. This way you don't need another page, just JS.
On another note, could you please post the extensions you found that do this?

Command Link Without page redirect

I want to click on an image (commandLink) which redirects to a controllers that calculates the number of clicks and updates a field in the object on return i do not wish to redirect the page however a pop up window should appear to let the user download a file from Documents.
Here's my code. Can someone tell me how to get the outputlink working.. my counter is working fine though.
<apex:pageBlockTable value="{!Docs}" var="d" rendered="{!if(Docs.size>0,true,false)}">
<apex:column >
<apex:commandLink action="{!incrementCounter}">
<apex:image url="{!URLFOR($Resource.LibraryImages)}" title="Click to Download" />
<apex:param assignTo="{!SelectedId}" name="selId" value="{!d.Id}"/>
<apex:outputLink value="/servlet/servlet.FileDownload?file={!d.Document_Id__c}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Downloaded" >
<apex:outputText value="{!d.Counter__c}" />
</apex:column>
</apex:pageBlockTable>
-------------------------------------------
public pagereference incrementCounter()
{
UpdateCount = [select id, counter__c from Document_Details__c where id =:SelectedId];
Decimal num= updatecount.counter__c;
updatecount.counter__c=num+1;
update updatecount;
Docs.clear();
// to get the updated values from the object
Docs=[Select id, Name__c, Document_Id__c, counter__c,Uploaded_by__c,Type__c,Description__c,Document_Created_On__c,My_Library__c From
Document_Details__c where My_Library__c=: MyLib.id];
return null;
}
I tried to partially refresh the page using outputlink, action support and rerender but that didn't work so i thought of using commandlink.
Elements such as <apex:actionStatus> and <apex:commandLink> have javascript events you can leverage to perform this kind of thing, so I would do something like the following in your page:
<apex:commandLink action="{!incrementCounter}"
oncomplete="window.open('/servlet/servlet.FileDownload?file={!d.Document_Id__c}');">
<apex:image url="{!URLFOR($Resource.LibraryImages)}" title="Click to Download" />
<apex:param assignTo="{!SelectedId}" name="selId" value="{!d.Id}"/>
</apex:commandLink>
That way, you call your method to increment the counter, and once that's done the document is opened in a new window as you require.

mvc 3 sitemap provider- multiple paths pointing to same node

i've recently started to use marteenba's sitemap provider, because i couldn't solve a route problem with the other sitemap i had. It's way better than my previous one. My question is: how can i create different breadcrumb trails from pages that go to a single main page? Consider the idea below:
Sitemap Structure
<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
<mvcSiteMapNode title="Clients Search" controller="ClientBussiness" action="ClientSearch" description="Clients Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Advanced Search" controller="ClientBussiness" action="AdvancedSearch" description="Clients Advanced Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Another Search" controller="ClientBussiness" action="AnotherSearch" description="Clients Another Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
</mvcSiteMapNode>
On the example above, my breadcrumb trail always shows the node Clients Search instead of any other. I don't know if should create different routes for each kind of search (i did this on my last sitemap, but unfortunately iis6 didn't like it).
I appreciate your help.
EDIT
searching on forums i found a similar question. So, consider the structure below:
Home >> Search >> Contracts
Home >> Another Search >> Contracts
Home >> Advanced Search >> Contracts
Home >> Web Service Search >> Extra fields >> Contracts
Well it seems that all i needed to do was to add some dynamic nodes attributes on my controllers. You can read how to do it here. Using the example above, here's how it's done:
[MvcSiteMapNodeAttribute(Title = "Search", Key = "search", ParentKey = "ContractSearch", Route = "SearchRoute")]
[MvcSiteMapNodeAttribute(Title = "AdvancedSearch", Key = "ContractAdvSearch", ParentKey = "AdvSearch", Route = "AdvSearchRoute")]
[MvcSiteMapNodeAttribute(Title = "AnotherSearch", Key = "ContractAnotherSearch", ParentKey = "AnotherSearch", Route = "AnotherSearchRoute")]
public ActionResult ContractIndex()
{
//Things to do...
}
On the example above, each kind of search will be properly defined on the breadcrumb trail.
Keep in mind that you have to define different routes for each kind of "search" you want to use. So, if you want to have 3 nodes pointing to the same url, each node must have it's own route and it's key, defined on MvcSiteMapNodeAttribute.

Resources