I have multiple links in table. Each row represents a link. I want to redirect the link into another page for its description. To implement it, I want to use a common template where based on the clicked link, dynamically the HTML page will be filled with the information. The url needs to be dynamic too, appended by the clicked value. All these needs to be implemented in flask framework.
Eg: http://bearch.herokuapp.com/query
Whenever I click more, it should redirect to another HTML page which should be dynamic, instead of hardcoded as in case of http://bearch.herokuapp.com/100YearsofSolitude
All clicks should send a request and response from the server should be dynamic HTML page based on the clicked link. The url should also be generated based on the clicked link.
you can embed the item identifier in links
item 1
and in route you can extract the identifier
#app.route('/items/<item_identifier>')
def show_item_info(item_identifier):
print item_identfier
# query the db for item and assign it item
# pass the item to template
return render_template('item.html',item=item)
here item.html is the generic template for each item and you can now render it by template expressions ex {{ item.description }}
Related
I'm using Laravel 5.8 to develop a project. I have a page which contains a button, clicking on it will redirect you to a registration page. This button is located in multiple pages, so, when the button is clicked, I want the name of the page from which it was clicked to be shown in the URL.
For Example, take this Youtube link, https://www.youtube.com/watch?v=dQw4w9WgXcQ
The /watch?v=dQ part, I want to have that in my URL, where "watch" would be the current page's name, and v would contain the name/id of the previous page. I have posted the button and the routes below.
Let me know if something else is required.
Request a Demo
Route::get('demo','Controller#dropdown_data');
Route::POST('demo','Controller#submit');
The get route calls a function to retrieve data for dropdown fields from a database.
The post route calls the function for submission of the details.
With the url() helper it is not possible to add URL query parameters. However, when you add a name to the route, you can use the route() helper like this on your pages:
<a href="{{ url ('demo', ['prev' => 'nameOfCurrentPage')}}" class="set-btn btn3">
Request a Demo
</a>
And like this as your route definition:
Route::get('demo','Controller#dropdown_data')->name('demo');
I'm trying to find code or a way to process the following:
When you click a button a site it'll go and read specific website link and then return variables that it finds in the remote page.
1) user clicks button
2) query goes to www.whatever.com/myfile.html
3) there is a specific p tag inside a div tag called 'totalamount' = <div id=WTextWrapper><p id="Amount">2,000</p></div> That I want to grab the value of and then display it on my page below the button that I clicked in step 1
I know there is a way to do it, but I have no idea how it's done.
You need to get the source of the html and use regex to extract what you need. You can use file_get_contents() function to get the source html.
I am having one html page for recommendation.
In this page I have different buttons like choose contact, choose merchant. In choose merchant button, I have one textbox, after clicking on the button I will navigate to the page which contains the list of merchants.
After clicking on merchant name, that merchant name should displayed in textbox of recommend.html (first html page), but its not possible as the textbox id belongs to different html page and that merchant name id belongs to different html page.
I m able to append that merchant name to the same html page of choose merchant but can't append it to the recommend.html..anybody knows solution for this,..?
In a simple code example, using HTML5's session storage,
On your merchant list page, before bouncing back to the recommendation page, set the session storage item when the merchant is selected:
sessionStorage.setItem("selectedMerchant", "merchant_name");
On the recommendation page, read the item and display recommendations based on the selected merchant name:
var selectedMerchant = "";
if ( sessionStorage.getItem("selectedMerchant") ) {
selectedMerchant = sessionStorage.getItem("selectedMerchant");
}
Of course, you will need to handle various conditions, such as clearing the selected merchant names and validating the values, etc.
Check out the link below for more references:
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage
You need to generate that html code and have to pass it in that page using jquery
For example if that element is like "#merchant" and generated html is like $("") then append it to selected element using insertAfter or appendTo
When you click on second.html (where ever merchant name exists), you need to submit a html form with action attribute to recommend.html and pass the merchant name as a hidden input type .
Then from second.html, you can access the POST parameters and display it in your text box.
Basically you need to have some server side coding (JSP/PHP/PERL etc)
I have Facebook iframe app where I am pulling content with JSON and representing it in a list with search criteria.
On item click new content shows on the same page (using ajax), and that page shows more info about item. I want to add a LIKE button for every clicked item.
But it must be a different URL so I can publish it on my FB wall. So when I check link from Like button on wall, it will redirect me on that special item.
Here are few issues:
1) How to define Like button for every item?
<div class="fb-like" data-href="LINK FOR LIKE BUTTON" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true" data-colorscheme="dark"></div>
Here is LIKE button, I need to specify different data-href for every item.
2) I need to send some parameters to url. Let's say when clicking on item, I should send item id to URL. Right now I can send item id to my URL but it is doing just in my iframe -- not in facebook URL. How can I do this?
I think second problem would give an answer for my first problem.
Edit: I am doing this using jQuery.
edit2:
so, i am using jquery for my site, pulling content with JSON and representing it with html and jquery, i have, it is all the same page, but on click i hide some contents and show another, so my main content is a list of items, click on item i hide main content, and i show item info content
so, it is all one page, so it has the same URL (main content, item content,... all the same URL)
so for adding LIKE buttons for every item, i need to make a difference between those items, so i done this
'window.location.href=window.location.href + "#id=" + propertyid;'
so right now, every item has its own URL, which i done manually, so right now every item has own URL which i could use for LIKE button
but, when i alert this new window.location.href is seems all right, i get this new location with #id=12345 included, but when i try to send that location to LIKE button data-href it is always just the main location, without this new part includind item id #id=12345
Yes, you can create FB Like buttons for "items" shown on dynamically created screen content (eg Ajax popups).
Issues:
Individual item urls
FB demands a "social graph endpoint" for each item that can be liked. So you also need to support a url which returns only the "item." This is the url for the individual item. It is also the url that a FB viewer will click on if they want to find out more about the item.
Example: a page shows a list of articles. There is an individual Like button next to each article. When a person "Likes" article B, it is shown in their FB stream. When they click on "Article B" in the stream, it should go to a page that only shows article B.
Also, the url for just article B will be queried by Facebook to obtain the FB meta headers for the individual item (image, classification, etc).
Parsing the new dom for FB items Depending on which method you use for adding FB like buttons et al, you may need to tell FB to explicitly (re-)parse the new parts of the dom that you just added dynamic content to. (Your pop-up.)
Since you know the element that you added the popup to, there is no need to tell FB to reparse your entire dom. Tell them to parse starting at the beginning of your newly added/changed element:
Code I use:
if (event_data) { // event_data was received, show it
panel.setBody(event_data); // set the pop-up's body
if (!this.ie && typeof(FB) != "undefined" && FB.XFBML)
{FB.XFBML.parse(this.panel_el);} // Parse FaceBook markup
....
Docs from FB on this:
http://developers.facebook.com/docs/reference/plugins/like/
http://developers.facebook.com/docs/opengraph/
http://ogp.me/ # FB site about "Open Graph Protocol"
Place this in a for loop, and you should be fine.
var elements = $("#divId").html();
$("#divId").html(elements + "like button code");
$("#divId.fb-like").attr("data-href", "what you want to link to");
See .html() and .attr() specs.
I have a list that is automatically populated from an XML DataSource using bindings.
Each XML record contains a title, a description and a URL
Each UI row contains a title and a description.
When onclick is called on the title, I would like to call the openURL with the URL specified in the DataSource.
Is it possible to identify the current selection and navigate in the datamodel from the onclickHandler?
In a Dashcode project I'm working on right now I have a datasource that includes a URL to the product on Amazon.com. I haven't done this from the list view, but from my detail view I created a link to the Amazon page for the currently displayed product.
On the detail layout the URL field is transformed to be:
"Click here to purchase the product on Amazon.com."
And the word here is a standard html link.
I used a Value Transformer to do this. In my data source the URL field contains a fully qualified URL to the product on Amazon.com. So where you see "value" in the code below Dashcode is replacing that with a URL in the HTML code that is then included in the page.
myBuildAmazon = Class.create(DC.ValueTransformer,{
transformedValue: function(value){
// Insert Code Here
value="Click <a href="+value+" target='_blank' >here</a> to purchase the product on Amazon.com.";
return value;
}
});
One important thing is that when you bind the datasource to the field select HTML from the popup menu that comes up rather than Text.
I hope this helps.