Using resource files in SharePoint MasterPages - sharepoint

I haven't been able to figure out how to use strings from resource files (resx) in SharePoint master pages.
I know how to use it with server controls, but can I somehow extract a value and use it in generalt html. I.e. in an alt attribute on a img tag?
<img src="photo.jpg" alt="my_resource_entry_here" />

Here are 2 very good blog posts that describe how to use resources:
http://tomblog.insomniacminds.com/2008/02/25/sharepoint-internals-resources/
http://www.mikhaildikov.com/2007/03/sharepoint-resources-types-use-and_2163.html

The easiest way would be to add a runat="server" attribute to your alt tag. That will solve your problem and you can use the "normal" way of getting resources.
Othwerwise use this syntax to get value from the resx files places in App_Global resources:
<img src="photo.jpg"
alt='<%=this.GetGlobalResourceObject("Global", "Mystring").ToString()%>'

I assume you have a class with a method that lets you get the resource string by the key, e.g. MyResources.GetString(key). In that case you can use something like this:
<img src="photo.jpg" alt='<%=MyResources.GetString("my_resource_key_here")%>' />

Related

Extract multiple image links from a single div tag that has no class name

Hi I have this HTML code from a website: I want to be able to extract multiple images, I have cases where there is 3-4 images. How would I go about doing that?
<div style="float: right;"><u>Chakra required:</u>
<img src="https://naruto-arena.net/images/energy/energy_2.gif">
<img src="https://naruto-arena.net/images/energy/energy_4.gif">
</div>
My code:
chakras1 = soup.find_all("div")[42].img['src']
print(chakras1)
Result:
https://naruto-arena.net/images/energy/energy_2.gif
I only get the FIRST image but now the second one.
To extract multiple images from within a tag, I personally stick to using for loops. So what I mean is once you find the div tag that you want to look within and say you call that chakras1, I would write the following:
for img in chakras1.find_all("img"):
print(img)
For me the steps kind of go as follows:
find the specific tags you are looking for (img src)
see what tag those tags are within (
navigate through the HTML to that tag (using beautiful soup's .find or .find_all functions depending on what you want to use)
once you have navigated to the tag search within that tag for the tags you're really looking for.
One quick note, with this method, if you are looking through multiple div tags, you're also going to need to loop through those as well.
I hope this makes sense!

Cannot identify the object in Selenium

I cannot identify the object of the icon showed in the attached screen shot. I have shown the HTML code as well.
The ID's are getting changed dynamically.
Can anyone guide on how to identity this kind of objects in Selenium?
If the ID is always changed, I recommend using CssSelector instead.
For instance,
<div id="running_number_12345" class="icon something">...</div>
You can use locator
driver.FindElement(By.CssSelector("div[class*='icon something']"));
If your icon doesn't have any specific css pattern, I recommend adding something in class attribute. If not, you have to use complex CssSelector to find it.
Try this
driver.findElement(By.cssSelector(".icon something"));

Is it possible to add some arrows to ms2gallery and use it as carousel?

I have project on modx and there is used ms2gallery to show images. And customer want to add some arrows(prev, next) to use this ms2gallery as carousel or slider. Is it possible to build-in this functional into ms2gallery? If not could you advice something to solve this task?
You can use the pdoPage snippet for just this purpose. Here's the example form the ms2Gallery documentation:
[[!pdoPage?
&element=`ms2GalleryResources`
&parents=`0`
&tpl=`#INLINE
<p>
[[+pagetitle]]
<img src="[[+120x90]]" title="[[+120x90.name]]" />
</p>
`
&typeOfJoin=`inner`
&includeThumbs=`120x90`
&includeOriginal=`1`
]]
[[!+page.nav]]
You will need to add some extra properties to the snippet call to get more than one result. All the available options and several examples are documented on the pdoPage readme.

ExpressionEngine add class to wrap parameter

I have entries that contain an image as a channel entry field. I am using the following syntax in my template to generate an alt tag w/ data. The problem I have is that I haven't found a way to add a class attribute to the generated img tag.
{info-image wrap="image" class="img-responsive"}
outputs
<img src="http://secretproject.dev/images/uploads/general/dedication2.jpg" alt="dedication2">
where the alt data is the image title.
If I take another approach and write
<img class="img-responsive" src="{info-image}" alt="{title}">
then the title comes from the entry itself and not the file title.
In summary, I need both class and alt attributes but seem to be stuck with one or the other. Is there a way to achieve this in either syntax? Is there another approach? Thanks
You can use the variable pair syntax as described in the documentation.
{info-image}
<img src="{url}" alt="{title}" class="img-responsive">
{/info-image}

Display content part in Orchard

I would like to be able to specify exactly where a ContentPart is rendered in a view.
For example, in my Content.Summary.cshtml I want to wrap my title and first image from the gallery (I'm using ZenGallery) in an anchor tag. I thought I would be able to do it like this but the gallery template is not rendered.
<a href="#Url.ItemDisplayUrl((IContent)Model)">
<h2>#Model.ContentItem.TitlePart.Title</h2>
#Display(Model.ContentItem.ZenGalleryPart)
</a>
But if I do the following then the gallery template (ZenGallery.Summary.cshtml) is shown along with all other parts.
#Display(Model.Content)
I understand that the recommended way to do this is probably using Placement.info, is that right? But this way makes more sense to me and would allow for more fine grain control of the end markup. How could I achieve the markup I'm looking for?
This should give you a pretty good start on doing precisely what you want: http://weblogs.asp.net/bleroy/archive/2011/07/31/so-you-don-t-want-to-use-placement-info.aspx

Resources