Href link change in Anchor tag in Module in sitefinity - sitefinity-5

I have create a module in sitefinity field like title description(rich textbox).
When adding detail in module like description detail :
"(title) :- Heading 12
(Description) :- loren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsumloren lumsum?
Read More "
In description adding link using dynamically so text of anchor link is :
Read More
And when module use in user control
public DynamicContent RetrieveHomePersonalisedtextitemThroughFiltering(string title)
{
var providerName = String.Empty;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type homePersonalisedtextitemType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Home_PersonalisedText.Home_personalisedtextitem");
var myFilteredCollection = dynamicModuleManager.GetDataItems(homePersonalisedtextitemType).Where("Title = \"" + title + "\"");
var myFirstFilteredItem = myFilteredCollection.Last();
return myFirstFilteredItem;
}
And the drag module on this page than anchor link text is
Read More
it is asign the guid in href.How to solve this problem in usercontrol.

I believe this blog post will help you:
http://www.sitefinity.com/blogs/stanislav-velikovs-blog/2013/02/15/dynamically-resolving-sitefinity-links-when-using-htmlfield

Related

Property Metadata Binding Assertion Failed

I have a View in my SAPUI5 application where I am creating a OData Model.
In the next step I want to use his metadata to bind a Property.
My error message is
abap.js:64 Assertion failed: COLUMN/#sap:label is not a valid property path
I think here is another mistake because before i tried this, I had always a OData Model which i defined in the manifest file and it worked fine - but now when creating a Model in the same view it doesn't work.
I also thougt about to set the Model to the View, but I think its not neccessery because in the Path I am saying, please look at "oModel" OData Model for your data. {oModel</....
Did I forgot something?
// creating model
var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/", "oModel");
var oLabel = new sap.ui.comp.smartfield.SmartLabel({
text: "{oModel>/#showcase/" + column + "/#sap:label}" // {ODataModel>/#showcase/" + column + "/#sap:label}" //
});
the "oModel" inside the line
text: "{oModel>/#showcase/" + column + "/#sap:label}"
refers to a name, under which you can assign the model to any Control that is inherited from sap.ui.base.ManagedObject. it has no relationship to the variable name "oModel" that you use to create the model in JS.
the following should work (note, I replaced one occurrence of oModel with bla, the other with blubber to point out the difference
var bla = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/");
var oLabel = new sap.ui.comp.smartfield.SmartLabel({
text: "{blubber>/#showcase/" + column + "/#sap:label}"
});
oLabel.setModel(bla, "blubber")
or, alternatively:
var oLabel = new sap.ui.comp.smartfield.SmartLabel({
models: {
"blubber": new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/")
},
text: "{blubber>/#showcase/" + column + "/#sap:label}"
});

How to extract the "href" attribute of <a> and paste it in a Google sheet?

I would like to extract an HTML anchor's ( < a href="" >Link here< /a > ) "href" attribute from the following page:
https://tvm.liga.nu/cgi-bin/WebObjects/nuLigaTENDE.woa/wa/teamPortrait?team=2368692&championship=K%C3%B6ln-Leverkusen+Winter+2019%2F2020&group=18
and put it in my google sheet.
I tried several xpath expressions for this page but it is everytime "N/A".
Still the simple xpath doesn't work, e.g.
importxml("https://tvm.liga.nu/cgi-bin/WebObjects/nuLigaTENDE.woa/wa/teamPortrait?team=2368692&championship=K%C3%B6ln-Leverkusen+Winter+2019%2F2020&group=18";"//tr")
What am I doing wrong?
Thanks Tanaike for all of your efforts.
I changed the script a little bit, because the result is based on pure html and needs to be changed so that the link could be clicked.
function getWebsite(url, searchText, baseURL)
{
var html = UrlFetchApp.fetch(url);
var text = html.getContentText();
var re = new RegExp('(?<=<a href=")(.*)(?=">.*' + searchText +')',"g");
var link = text.match(re)[0];
if (link !== null)
{
var link = text.match(re);
link = link.replace(/&/g,"&");
link = link.replace(/"/g,"\"");
return baseURL + link;
}
else { return "not found"; }
}
It depends which information you're looking for, but for example...
A1: https://tvm.liga.nu/cgi-bin/WebObjects/nuLigaTENDE.woa/wa/teamPortrait?team=2368692&championship=K%C3%B6ln-Leverkusen+Winter+2019%2F2020&group=18
A2: //table[2]/tbody/tr/td[6]/a/#href
A3: =IMPORTXML(A1,A2,1)
To find A2 - in Chrome - right-click a link of interest and "Inspect." Right-click on the href of interest to you, and "Copy full XPath."
Delete the part before the table reference, but leave TWO "/"s before the table reference. Then, delete the reference to the specific row following "tr", i.e., the "[x]". This way you'll select the entire column - in this case "[6]"
Fiddle as necessary.

Aspose.Words delete line(row) containing a Bookmark

I have a very basic helper method that sets Bookmark's text.
public static Bookmark SetBookmark(this Document doc, string bookmarkName, string value)
{
var bm = doc.Range.Bookmarks[bookmarkName];
if(bm == null)
throw new NullReferenceException(string.Format("Bookmark {0} Not Found!", bookmarkName));
bm.Text = value ?? string.Empty;
return bm;
}
What I need is to remove a bookmark and delete line of text that contains it when a certain condition is met, e.g. when value == null. Any suggestions?
Sample document looks like:
Hello
[Bookmark]
Goodbye
Resulted document after removal:
Hello
Goodbye
Please set the value of Bookmark.Text property to empty string to remove its content and use Bookmark.Remove method to remove the bookmark from the document. Bookmark.Remove method does not remove text inside the bookmark.
I work with Aspose as Developer evangelist.
Please set the value of Bookmark.Text property to empty string to remove its content as shown in following code example. I already shared this in my previous answer.
Document doc = new Document(MyDir + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.Range.Bookmarks["MyBookmark"];
// Remove the contents of bookmark.
bookmark.Text = "";
doc.Save(MyDir + #"Out.docx");
I work with Aspose as Developer evangelist.

Grails controller not getting current value of a dropdown in a controller

I have a dropdown (g:select) in my view that displays a list from a domain class. I want to println whatever value that is in it whenever a save button is clicked. Below is the script in the view
<g:select params="[tablename: storehouseInstance?.tablename]" name="tablename" from="${Warehouse.list()}" optionKey="id" optionValue="${Warehouse.list()}" value="tablename"
noSelection="['':'Choose Table']"
onchange="${remoteFunction (
controller: 'warehouse',
action: 'updateSelect',
params: "'warehouse.id=' + this.value + storehouseInstance?.tablename" ,
param: "this.value",
update: [success:'fieldSelection'] //update: 'fieldselection'
)}"/>
And in my controller i have:
def save() {
println("params are "+ params)
println("Saving table name: " + params.tablename)
}
I am getting tablename to be '1' instead of the value that should be something like 'MYTESTVALUE'
Any help please.
Assuming the warehouse's name property is name, try this instead:
<g:select params="[tablename: storehouseInstance?.tablename]"
name="tablename"
from="${Warehouse.list()}"
optionKey="name" // I changed this line
optionValue="name" // I changed this line too
value="tablename"
noSelection="['':'Choose Table']"
onchange="${remoteFunction (
controller: 'warehouse',
action: 'updateSelect',
params: "'warehouse.id=' + this.value + storehouseInstance?.tablename" ,
param: "this.value",
update: [success:'fieldSelection']
)}"/>
In a g:select the parameter that is sent to the server is defined by optionKey and the value that is displayed in the dropdown is defined by optionValue
Aside
From an MVC purity point-of-view, you shouldn't be doing queries in GSPs, e.g. Warehouse.list(). Instead you should retrieve the data you need in a service/contoller and pass it via the model to the view (GSP).

MVC3 EF Search DB fields but strip HTML

I am using the entity framework with MVC3 and am trying to do a search on a description field but the problem is that description field has HTML in it eg "< div class="section" />". Can i do a funky search that searches only the stuff outside of the HTML tags?
return context.Categories
.Where(i =>
i.Name.Contains(searchText)
&& i.Description.Contains(searchText)
)
Thanks in advance!
Give HtmlAgilityPack a go. It has methods for extracting the text out of an HTML Document.
You basically just need to do the following:
var doc = new HtmlDocument();
doc.LoadHtml(htmlStr);
var node = doc.DocumentNode;
var textContent = node.InnerText;
Or the much less awesome method:
public static string StripHTML(string htmlString)
{
string pattern = #"<(.|\n)*?>";
return Regex.Replace(htmlString, pattern, string.Empty);
}
All together
return StripHTML(context.Categories.Where(i => i.Name.Contains(searchText)&& i.Description.Contains(searchText)))

Resources