I need to retreive the plid of a portlet in my theme(.vm).
Can't find an appropriate way to do this.
I need to open My Account portlet as a popup. The code for this is to be written in the theme.
I am using
#set ($my_url = $portletURLFactory.create($request, "2", $getterUtil.getLong($plid), "RENDER_PHASE"))
and then using the url in anchor tag:
<a style="color: #ffffff" href="$my_URL">Click Here</a>
But on click i am redirected to blank page.
Why is that so?
Below is the code to get plid(pageId in vm)
#set ($themeDisplay = $request.get('theme-display'))
#set ($currentPlid = $getterUtil.getLong($themeDisplay.get('plid')))
Related
I am looping some specific products on the home page but unable to generate the ADD TO CART URL in magento 2
How to generate ADD TO CART URL when displaying products in loop.
I know it's been a year since this has been touched on, but as I've just done what has been requested, I thought that I may post my solution to help others.
The other answers will work, but only for simple products, where no further input is required (e.g. selecting options). When using getAddToCartUrl(), Magento first checks if the products requires any options to be selected; if it does, then it will simply supply the URL to the product page instead.
To skip all of these checks and directly obtain the add to cart URL, then make use of the Magento\Checkout\Helper\Cart helper instead. If you are within a .phtml file, then this can be utilised simply by calling $this->helper:
$cartHelper = $this->helper('Magento\Checkout\Helper\Cart');
From there, you can generate the add to cart URL via getAddUrl(), ensuring you pass the product object as the parameter:
echo $cartHelper->getAddUrl($product)
For it to fully work, you must have a hidden field for the form key as described in the other answers, and if the product in question has compulsory options to choose from (e.g. a configurable product), then make sure you include those fields as well, otherwise you will get redirected to the product page itself, with a message informing the user that options are required.
The excellent solution is to use
$cartHelper = $this->helper('Magento\Checkout\Helper\Cart');
and after that
echo $cartHelper->getAddUrl($product);
this give add to cart URL every time
(for a simple product, for a simple product with custom options etc)
use following to generate add to cart URL in magento2:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($product);
Add your button code into form with form key.. It will work
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($product);
<form data-role="tocart-form" action="<?php echo $addToCartUrl; ?>" method="post">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="Add to Cart"
class="action tocart primary">
<span>Add to Cart</span>
</button>
</form>
You can generate "add to cart" url by following code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($_product);
In the Typo3 backend I'm redering my email body with a Fluid template. In the following way:
$emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$templateName = 'path/to/email/template.html';
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . $templateName;
$emailView->setTemplatePathAndFilename($templatePathAndFilename);
$emailView->assignMultiple($variables);
$emailBody = $emailView->render();
In the loaded email template I'm making an absolute link to a page with the following line:
<f:link.action absolute="true" pluginName="name" extensionName="extName" pageUid="{PageId}" controller="Ads" arguments="{uid: uid}">Klik hier</f:link.action>
This is generating a working link only it is not processed by RealURL. Is it possible that is will be done?
You need a valid frontend context for realurl to work. Therefore I suggest that you move your email template to a page type and use a subrequest to render the HTML.
Seems like it should be straightforward but I can't seem to get to the bottom of it.
Here's the HTML I'm working with:
<li id="a" class="FILElevel3" onclick="changeMenu("b")">
<a onclick="stopBubble(event);" href="javascript:LinkPopup('/sub/URL.html')">Visible Text</a>
I'm able to find the element using XPaths:
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']");
And I can verify this works because I'm able to extract the visible text from it:
my $returned_name = Selenium::Remote::WebElement::get_text($returned_asset);
I just can't seem to find the sequence to pull the HREF attribute from the element to put the link's URL into a verifiable string. Should I be able to do this using WebElement's get_attribute() method? I've tried variations on this:
my $returned_URL = $returned_asset-> Selenium::Remote::WebElement::get_attribute("a/href");
...where I've plugged in everything I could think of for that "a/href" string. What should go in there?
In the end I'd like to be able to put "javascript:LinkPopup('/sub/URL.html')" into a string and verify that my URL is in there.
have you tried
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']/a");
my $returned_URL = $returned_asset->Selenium::Remote::WebElement::get_attribute("href");
im using snipper tag system and following below article:
http://daniel.streefkerkonline.com/tag/umbraco/
i can install and use snipper tag system successfully. but when i browse the page..tags appear as text and not hyper link...
Am i'm missing something. IS it some javascript file or im missing some step to include tags?
Any ideas?
here is my page:
http://www.leezardpharma.com/pharmacy/our-products/weight-loss-medicine/gastro1.aspx
here relevant tags are coming becuase of snipper ..but they arent clickable.
If you need to create tags as link with option to display the products which are tagged then you can create new page called ../search.aspx?tag=tagname
and then search for the products which are in that TAG, code is as below:
#inherits umbraco.MacroEngines.DynamicNodeContext
#using System.Text
#using umbraco.MacroEngines
#using umbraco.cms.businesslogic.Tags
#{
string searchFor = Request["tags"];
if(string.IsNullOrEmpty(searchFor))
{
#* No tags were specified *#
<p>Please specify a tag to search for</p>
return;
}
// this is to search from the tags added and then get all the nodes
var matchingNodes = Tag.GetNodesWithTags(searchFor).ToList();
string tagsText = searchFor.Split(',').Count() > 1 ? "tags" : "tag";
if (matchingNodes.Count < 1)
{
#* No results were found for the specified tags *#
<p>No tagged items were found that matched the #tagsText: #searchFor</p>
return;
}
#* Some results were found for the specified tags *#
<p><strong>#matchingNodes.Count</strong> products were found that matched the #tagsText: "#searchFor"</p>
<ul>
// go through the code and create URL for that product
#foreach (var node in matchingNodes)
{
dynamic dn = new DynamicNode(node.Id);
<li>#dn.Name</li>
}
</ul>
}
you can refer to this article as I have checked it click here and half way down you will see this code
Let me know any more explanation need. I have commented this so that you can get briefing of the code.
You sure you're doing this?
<ul>
#foreach (var node in matchingNodes)
{
dynamic dn = new DynamicNode(node.Id);
<li>#dn.Name</li>
}
</ul>
Something doesn't look right here, where you're displaying your tags:
Where are those two links coming from?
There's no javascript or anything fancy needed. This is all done in razor on the server-side.
I wrote the sniper tagging control.
If you want friendly URLs for the tags,
Create a rewrite rule to map /tags/([\w]*) rewrite to tagsearch.aspx?tag=$1
Then implement tagsearch.aspx to take that tag parameter and return any pages containing it as explained above.
I'm working with Perl and the WWW::HtmlUnit library to access the following site:
https://www.cnatra.navy.mil/scheds/schedule_data.aspx?sq=VT-7
I can load the page, click on the "view Schedule" and "search" buttons, but I can not click on one of the numbered days in the ctrl calendar.
I have been looking at the click() function, but I must define the link I'd like to click on as an element before this function can be called.
Any ideas how I could actually get the program to find and click these links?
Here's the code from the site describing the link I'd like to click:
<td align="center" style="width:14%;">
<a href="javascript:__doPostBack('ctrlCalendar','4241')"
style="color:Black" title="August 12">12</a>
</td>
Here's the simplified code I will put it in:
use WWW::HtmlUnit;
use Inline::Java;
my $webClient = WWW::HtmlUnit->new;
$webClient->setUseInsecureSSL(1);
my $page = $webClient->getPage("https://www.cnatra.navy.mil/scheds
/schedule_data.aspx?sq=vt-7");
###define $daylink element here. This is the calendar link I want to click
my $sched = $daylink->click();
my $content = $sched->asXml;
print "\n$content\n\n";
Since neither the table nor TR/TD nor links have IDs/names, you need to find the appropriate element via attribute search. Luckily, HTMLUnit provides an API just for that: getOneHtmlElementByAttribute .
Try something like this (not tested as I have no access)
my $ancestor = $page->getBody();
my $daylink = $ancestor->getOneHtmlElementByAttribute('a', 'title', 'August 12');