tagging in umbraco 4.11 just like stackoverflow - content-management-system

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.

Related

Links at the start of content elements

TYPO3 adds these links at the start of almost every element:
<a id="c1427"></a>
where number is, I guess, UID of the element.
How TYPO3 render this link and is it possible to disable it for a specific FCE?
It depends on your TYPO3 Version. In 4.5 it is defined via:
tt_content.stdWrap.innerWrap.cObject.default.10.value = <div id="c{field:uid}"
If you use the TS-Objectbrowser, you should find it somewhere in tt_content.stdWrap.*
Depending on the rendering you are using, you could be able to add an if statement like:
tt_content.stdWrap.innerWrap.cObject.default.10 {
# check the uid of the content element which is rendered
if.isInList.field = uid
# do not render if content element uid is 1,2 or 44
if.value = 1,2,44
}
For sure, it depends on your configuration, so you cannot copy & paste. And i did not test this code! But it should show the way to go:)
I think your problem is in tt_content.stdWrap.prepend that is different for any languages different from default language.
Try to put this typoscript in your template:
tt_content.stdWrap.prepend >
tt_content.stdWrap.wrap = <div class="content-element">|</div>

Orchard - add class or id to the body using fields

My questions is - how do I add a class or id to the body tag using a text field within Orchard?
So if I enter the word "product" in the text field then the result should be <body class="product">. I want to use this method instead of creating alternate layout templates as every page has the same layout but I need a different class for each page to reference a different colour scheme I have setup for each page in my CSS.
I have added a text field with the name Area to the Title ContentType in the backend. My problem is now how to get the value of the field to be put into the body in the Document.cshtml.
I have read Setting Unique Body Classes and IDs in Orchard and Using Alternatives for Document.cshtml in Orchard CMS but I still can't get it to work! The second one seems like what I want to do but so far I have been unable to acheive it.
Any answer would be very appreciated?
Thanks
Andy
I am so frustrated that there is no readily available solution found in the net about this. Since I am more comfortable coding in jquery & js...
Here's my solution: Assuming you have jquery loaded...
#using(Script.Foot()) {
<script type ="text/javascript">
//<![CDATA[
$(document).ready(function () {
var url = window.location.pathname;
var count = url.match(new RegExp("/", 'g'));
var urlsplit = url.split("/");
var page_class = urlsplit[count.length];
alert(page_class);
$('body').addClass(page_class);
});
//]]>
</script>
}
The easiest way to achieve this is to use the Classy feature from Vandelay.Industries.

Determine active Page Object within Typo3

I'm writing a plugin which should add HTML to the page's head area (inludeJS to be exact). Something like this should work:
page.includeJS {
tx_myplugin_pi1 = EXT:my_plugin/pi1/tx_myplugin_fe_scripts.js
}
The problem with that is that I have to assume that "page" would be the universal name used for the page object I want to work with. Since the name of this variable can be anything I would like to do this in a more intelligent way than this.
Is there a way to determine the name of the current PAGE cObject I'm working with?
cu
Roman
You can find out the default PAGE object of the current page using this snippet:
$setup = $GLOBALS['TSFE']->tmpl->setup;
foreach(array_keys($setup) as $key){
if(substr($key, -1) == '.'){
if($setup[substr($key,0,-1)] === 'PAGE' && intval($setup[$key]['typeNum']) === 0){
print substr($key,0,-1) .' is the default PAGE object';
}
}
}
But this won't help you to add the Javascript in the frontend, as the typoscript is being parsed already at that point.
If you want to add the javascript just for your extension I would recommend using:
$GLOBALS['TSFE']->additionalHeaderData['tx_yourextension_plugin'] = '<script type="text/javascript" src="' . t3lib_extMgm::siteRelPath('my_plugin') . 'pi1/tx_myplugin_fe_scripts.js"></script>';
(this wouldn't be merged with the other JS files though)
Actually there is no such way in plain TypoScript. As most installations are using page as keyword - especially those which are under your control - it is really fine to use it.
If you are writing an extension, you can put that into the documentation as a small hint!

How do I access a Post Slug in a Tumblr theme?

I want to write a canonical tag into my Tumblr theme, and i need the slug for the (full) url. How can i access the posts-slug within the template? I just have access to the PostId. My current code looks like this:
<link rel="canonical" href="http://domain.com/blog/{block:PostTitle}post/{PostID}{/block:PostTitle}" />
What i want to have is something like this:
<link rel="canonical" href="http://domain.com/blog/{block:PostTitle}post/{PostID}/{PostSlug}{/block:PostTitle}" />
I tried the following tags (which obviously did not work...):
{slug}
{PostSlug}
{Postslug}
What amuses me is, that the API gives out a slug-key on every post, try:
http://(YOU).tumblr.com/api/read?debug=1
Thanks for any hints and suggestions.
Edit: I already scanned http://www.tumblr.com/docs/en/custom_themes for hints - but found nothing useful.
The post slug is not available as a token in Tumblr’s theme DSL. I’m not sure if this is an intentional omission, as post slugs are optional on Tumblr (you can manually set one, but if you don’t your post just goes by its numeric ID). However, you can parse it out of the link inserted by the {Permalink} token, i.e. include it in some hidden element in your template along the lines of
<span class="permalink-url">{Permalink}</span>
(hide the span if you will), then retrieve and parse it with JavaScript:
var plTags = document.querySelectorAll('.permalink-url');
for (i = 0; i <= plTags.length; i++) {
postSlug=plTags[i].replace(/.+\//, '');
// do whatever you want with the slug
}

How can I insert the current page title automatically into a TYPO3 template?

actually the title is the whole question.
I just want to modify the template so that the current page title is automatically shown (i'm working with html templates so I just need the bit of typoscript to get the page title out of the database)
I hope that's possible
It is. It's pretty simple to do. I'll assume you're using TemplaVoilà, because if you're not, you should be :-D
Start off by putting some HTML in your template with a dummy page title. Give it an ID attribute so it's easy to map. Like:
<h1 id="page-title">Page Title Here</h1>
Next, go into TemplaVoilà and map that <h1> element to the content type "TypoScript Object Path". When it prompts you for the object path, you can put in anything you want -- convention is that dynamic content is added in the "lib" namespace, so let's call it lib.pagetitle. When it asks you if you want to map this to "INNER" or "OUTER", choose "INNER" -- that will mean you're just mapping the space BETWEEN the <h1>...</h1> tags. ("OUTER" means you're replacing the whole element, including the tags, which we don't want here because we want this to stay an H1.) Save your template mapping.
Now go into your site's TypoScript template. Here you're going to insert the logic that fills in that space we just mapped with actual content. To insert the page title is a matter of a couple of lines of TypoScript:
lib.pagetitle = TEXT
lib.pagetitle.data = page : title
What this says is "take the space in the template that I mapped to lib.pagetitle. Create a content object in that space of type TEXT. Then fill that content object with the title of the page."
Save your TypoScript template. Now you're done!
This probably sounds complicated at first glance, and it is, but the nice thing about this system is that it's amazingly flexible. Inserting text dynamically is just the beginning. The TypoScript Reference (a.k.a. the "TSRef") has all the details -- look up "getText" to get a flavor, that's the function that makes the "page : title" call in your TypoScript template drop in the page title.
TSRef is your friend. I keep a printed copy of it at my desk -- if you want to make TYPO3 sing, it is your songbook.
I prefer the vhs solution:
{v:page.info(field:'title')}
https://fluidtypo3.org/viewhelpers/vhs/master/Page/InfoViewHelper.html
lib.pagetitle = RECORDS
lib.pagetitle {
source.data = page:uid
tables = pages
conf.pages = TEXT
conf.pages.field = nav_title
}
To get current page title:
lib.pagetitle = TEXT
lib.pagetitle.field=title
For meta data :
Its very important to place meta after header tag when we are gone through mobile compatible website
In order to prevent quirks mode in IE9 I need to add this lines at the very top of every HTML page:
You can write the whole header by yourself, by adding disableAllHeaderCode = 1 to your typoscript or you can hack it by adding your meta tag directly to the head tag:
page.headTag = <head><meta http-equiv="X-UA-Compatible" content="IE=edge" />
Place this at your typoscript
meta.X-UA-Compatible = IE=edge,chrome=1
httpEquivalent: (Since TYPO3 4.7) If set to 1, the http-equiv attribute is used in the meta tag instead of the “name” attribute. Default: 0.
For more information about TYPO3 stuff you may visit my blog
https://jainishsenjaliya.wordpress.com/2013/10/10/put-meta-tag-on-top-of-header-section-in-typo3/
If you want to use this in a fluid page template, you can also simple use:
{data.title}
to access the page title.
You can current page title by following typoscript:
lib.pagetitle = TEXT
lib.pagetitle.data = page : title
and then use this object to your page using typoscriptObjectPath like following way:
<f:cObject typoscriptObjectPath="lib.pagetitle"/>
If you want to use a fluid only solution, install the VHS extension and you can output the page title without using any TypoScript at all like this:
Tag Example:
<v:page.header.title title="NULL" whitespaceString="' '" setIndexedDocTitle="1">
<!-- tag content - may be ignored! -->
</v:page.header.title>
Inline Example:
{v:page.header.title(title: 'NULL', whitespaceString: '' '', setIndexedDocTitle: 1)}
lib.page_title = CONTENT
lib.page_title {
table = pages
select {
where = uid = 2
}
renderObj = COA
renderObj {
10 = TEXT
10 {
field = title
wrap = <h1 class="page_title">|</h1>
}
20 = TEXT
20 {
field = subtitle
stdWrap.required = 1
stdWrap.wrap = <h5>|</h5>
}
}
}
call the lib.page_title where want to render typoscript with this lines
<f:cObject typoscriptObjectPath='lib.page_title' />
I hope this helps !!!
The question is quite old but I still want to add something I never read here.
TYPO3 offers many things concerning the header, and it's right that it's also possible to render it completely individual. Nevertheless all the nice options of TYPO3 are more or less disabled by the individual solution.
So first the direct answer on the question:
The default page title can be overridden like this
config.pageTitle.stdWrap.override.cObject < lib.pagetitle
If several page types are defined and the title shall be set individually for each type, the configuration can be noted inside the page-definitions:
page = PAGE
page {
typeNum = 0
config.pageTitle.stdWrap.override.cObject < lib.pagetitle_1
...
}
anotherPage = PAGE
anotherPage {
typeNum = 1
config.pageTitle.stdWrap.override.cObject < lib.pagetitle_2
...
}
Below still a lib.pagetitle which makes a little bit more than only using title or subtitle - it uses news-title if the extension is used on a page:
lib.pagetitle = COA
lib.pagetitle {
10 = TEXT
10 {
// subtitle: used as field for title tag
value.field = subtitle // title
if.isFalse.data = GP:tx_news_pi1|news
}
20 = RECORDS
20 {
if.isTrue.data = GP:tx_news_pi1|news
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
}
}
Now still some background why I think some individual header might not be the best solution:
TYPO3 usually adds several details to the header, that are useful and it's not required to combine those things individually new.
Scripts and stylesheets are organized and can be even by TypoScript compressed and merged. If some syntax is followed it even takes care that a library like jquery is only included once.
TYPO3 has many functions in TypoScript where everything can be defined related to the header and also it can be decided if scripts shall be perhaps never be included at all in the header but instead in the bottom of the page-source.
Metatags can be defined (and overridden by extensions or sub-templates)
Implementing this whole logic manually again in an own template in my opinion is not useful and I think headers should be only disabled for special page-types like AJAX or dynamic PDF-files. This is the primary reason that I consider that option as useful.
Her still the current link for the most recent documentation about the config-options in TypoScript (anchor pagetitle):
https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#pagetitle