New bie here. I successfully installed django-autocomplete-light to my django-admin v1.4.
Is there a way to add a hyperlink after selecting an autocomplete-light widget which is a foreignkey field in models? I can only see an x icon to cancel the selected item.
The purpose of creating a link is to open a pop window to edit the records selected.
Thanks in advance for any advice
You have to add this '?_popup=1" target="_blank" onclick="return showAddAnotherPopup(this);' to your url.
Here is a complete solution.
`class EditModelBase(autocomplete_light.AutocompleteModelBase):
choice_html_format = u'''
<span class="div" data-value="%s">%s</span>
<img src="%s%s" />
'''
def choice_html(self, choice):
"""
Return a choice formated according to self.choice_html_format.
"""
choice_format = u'''<span class="div" data-value="%s">%s</span>'''
if not choice.get_absolute_update_url():
return choice_format
return self.choice_html_format % (
self.choice_value(choice), self.choice_label(choice),
choice.get_absolute_update_url(), _(u'Update'),
settings.STATIC_URL, 'admin/img/icon_changelink.gif')`
And:
def get_absolute_update_url(self):
url = reverse('admin:ccad_carrier_change', args=(self.id,))
url = '%s?_popup=1" target="_blank" onclick="return showAddAnotherPopup(this);' % url
return url
I hope it works.
Related
I hope you can help me out. (I'm a bit of a newbie.)
I have used functions.php to create two extra product fields and then show the input from these fields as well as a contact link/button below the short description on the product page.
Lets call this added content "mycontent" just to make it easier to explain the problem.
The weird thing is that now, if I go to a category page in admin and add anything in the "Description" field - then "mycontent" shows up above the products on the category page...?!
I have no idea how this is even possible?
But I would very much like it to stop...! ;o)
I have tried adding "mycontent" to my product page via other hooks from this page: https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/, but it doesn't show up. The only way it shows up is if I use woocommerce_short_description. But when I do that, it also shows up on category pages (only if there is a description on the category page).
I am confused on a higher level than normal... What am I doing wrong?
This is the code I use in functions.php to display "mycontent":
/* Show PDF link, PDF name and Contact Us on product pages */
add_filter( 'woocommerce_short_description', 'showpdflink', 3 );
function showpdflink($description){
global $product;
$link1='';
// Get the custom field value
$mypdfcol = get_post_meta( $product->get_id(), 'cop_pdflink', true );
$mypdfnam = get_post_meta( $product->get_id(), 'cop_pdfname', true );
// Display
//Build the links for the pdeffers
if( ! empty($mypdfcol) ){
$link1='<hr />
<div class="pdflink">
<div class="et_pb_row et_pb_row_13 et_pb_equal_columns">
<div class="et_pb_column et_pb_column_1_4"><img src="/wp-content/uploads/2022/12/pdf-icon.png" /></div>
<div class="et_pb_column et_pb_column_3_4">
<a href="'.$mypdfcol.'" title="Download pdf';
if( ! empty($mypdfnam) ){
$link1=$link1.' for '.$mypdfnam.'';
}
$link1=$link1.'" target="_blank" rel="noopener">Download pdf';
if( ! empty($mypdfnam) ){
$link1=$link1.' for '.$mypdfnam.'';
}
if( ! empty($mypdfcol) ){
$link1=$link1.'</a></div>
</div>
</div>';
}
}
/* Show CONTACT US button */
$link1=$link1.' <div class="contactbutton">
<a href="/kontakt-os" title="Kontakt CopyColor">
<span class="large">Ring for pris</span><br />
<span class="small">Klik her for kontakt</span>
</a>
</div>';
/* Show everything on the product page */
return $description.$link1;
}
/* End of Show PDF link */
I found the solution if anyone else can use it:
It turns out that woocommerce_short_description is used in several different places and then outputted in different hooks - so it showed up in both the product and the category description.
The correct place for me was woocommerce_single_product_summary.
My problem was that it wouldn't output the code. But by changing
return $description.$link1;
to
echo $description.$link1;
I got it to work.
what is the correct way to display the tag name on the tag specific page and a link to it in Modx revo using tagLister? e,g, a post has tags Tag1, Tag2 and Tag3. Now you click on one of the tags and it brings to the target resource displaying al posts with that single tag. What code to put in that target resource so it shows that the user has landed on the specific single tag page. I want to display the name and the link of that exact single tag.
My tags target resource is the main blog resource: Here is the code:
<section>
[[The Code to Display the Tag name to put here]]
[[!getResourcesTag#Blog Pagination Hy?
&elementClass=`modSnippet`
&element=`getResources`
&tpl=`Blog Post on Blog Page`
&hideContainers=`0`
&pageVarKey=`page`
&parents=`[[*id]]`
&limit=`3`
&includeTVs=`1`
&includeContent=`1`
&cache=`0`
]]
<div class="PaginationContainer">
<span class="TotalPages">p [[+page]] (total. [[+pageCount]])</span>
<ul>
[[!+page.nav]]
</ul>
</div>
</section>
is it possible at all?
Finally found on the web.
If you got better solution, please put it here.
So the idea is to make a snippet which gets the tag and call the snippet where we want.
Step by Step.
Step 1. Make a new snippet and name it something, e.g. Tag Name,
Step 2. Put the snippet code in the snippet code placeholder,
Snippet code:
//-- Get all request string key/value pairs
$s = $_REQUEST;
if($s['key'] == 'tags'){
return $s['tag'];
} else {
return false;
}
Step 3. Call the snippet where you want the tag nam to show up, e.g. [[!Tag Name]]
It will show up the tag name on tag pages only.
Here is where I found it
https://forums.modx.com/thread/11108/dynamically-generated-list-of-documents-that-are-tagged-with-categories?page=2#dis-post-397237
I searched a lot on net but couldnt find any solution. I am making a webapp in which I want 2 textbox to get data input from user. I want autocomplete feature in this textbox. The list of tags for autocomplete is available locally. I tried listview but what I want is that after user select some option from autocomplete hints, the textbox should have the selected value, and through some object, i should get the value of textbox to be used by javascript/php. This is a very basic thing, but I'm not able to do. Please help me out
I tried this jsfiddle.net/ULXbb/48/ . But the problem in this is that both listview gets same value after I select something in 1 listview.
In order not to add the same value to both search input, you need to target them using .closest(), .next(), .prev() and .find(). jQuery-Mobile, enhances list-view with data filter in a different way.
Demo
<form>
<input>
</form>
<ul data-role="listview">
<li>
<a>text</a>
</li>
</ul>
The form where the input is located, is on the same level of the ul. To target the input box, you need to use .prev('form').find('input'). Check the demo and the new code below.
$("input[data-type='search']").keyup(function () {
if ($(this).val() === '') {
$(this).closest('form').next("[data-role=listview]").children().addClass('ui-screen-hidden');
}
});
$('a.ui-input-clear').click(function () {
$(this).closest('input').val('');
$(this).closest('input').trigger('keyup');
});
$("li").click(function () {
var text = $(this).find('.ui-link-inherit').text();
$(this).closest('[data-role=listview]').prev('form').find('input').val(text);
$(this).closest('[data-role=listview]').children().addClass('ui-screen-hidden');
});
Thanks #user714852 I have extended your answer just add this line in the script tag:
$("#mylist li" ).addClass('ui-screen-hidden');
It will do wonders.
A working example: Listview Autocomplete - Enhanced
In my MVC application, user can upload various type of files (pdf, jpg, txt etc) and I want to show icon specific to each type, currently I am using one icon (pdf) for the purpose, I want, that based on the file type, associated icon should be displayed. Please guide me what kind of approach I can use for this purpose
<td>
#if (item.CalibratedBy != null){
<a href = #Url.Action("ViewCertificate", new { fileName = item.CalibrationCert }) >
<img src = "#Url.Content("~/Content/Icons/pdf.jpg")" alt = "attachment" /> </a>
}
</td>
Expose the extension type needed as a property on item (presumably being passed in through the Model)
Create an HtmlHelper extension method that will take in item.FileType and return the path to the appropriate icon file to be used. Call this in your <img> tag.
i want to create a input textbox with value link and write a code like this:
<form>
<input name="Textboxfield" type="text" value=".jpg"><br>
<input name="Launchlink" type="button" value="Launch link" onclick="location.href=this.form.elements['Textboxfield'].value">
</form>
this is a good code for me but have some problems.
in this code the value ".jpg" is variable but i wants to keep it stable who when user insert his/her number in textbox, can go to destination link.
for example:
i insert my number 22456 in this textbox like this: 22456.jpg
and when i press botton the page directly go to my file (a pic).
but
when i insert my number without .jpg format the page goes wrong and break the system (show index page)
and thats my problem! how can i have stable value link ".JPG" who when user jus isert his/her number to textbox the page directlty go to his/her file and show it.
also you can see this image:
http://0o.8415.2.img98.com/out.php/i543815_code.jpg
please help me guys...
Try this
<form><input name="Textboxfield" type="text" value=".jpg"><br>
<input name="Launchlink" type="button" value="Launch link" onclick="location.href=this.form.elements['Textboxfield'].value + '.jpg'">
</form>
You could check if the textbox value ends with ".jpg" using Javascript, and if it doesn't, append ".jpg" to whatever value is in the textbox. You could add this function to the onClick() handler of your button or somewhere.
You could write the function checkJPG() as:
<script type="text/javascript">
function checkJPG() {
var myText = document.getElementByID("myTextBoxID").value;
if (myText.substr(-1, 4) == ".jpg")
//do nothing
else
//append .jpg to the value in the textbox
}
</script>