disable TYPO3 link parsing in html block - php

In TYPO3 I used html blocks which contains a nav of hash-tags
<li class="navbox default">
About us
</li>
<li class="navbox default">
Shop
</li>
<li class="navbox default">
Images
</li>
<li class="navbox default">
News
</li>
<li class="navbox default">
Sale
</li>
<li class="navbox default">
Contact us
</li>
This nav is used for Bootstraps Scroll-Spy and the hash-tags represent content-elements. Everything works fine, but only for the page "/". If I open the page in another language like /de.html or /en.html, TYPO3 prepend this part to the href and I get something like this
About us
This is fine for most cases, but Bootstraps Scroll-Spy expect all links as a "pure" Hash without anything in front.
My question is now, how can I disable TYPO3 parsing of html blocks/link replacement? I don't want to modify the bootstrap js files

config.prefixLocalAnchors = 0 is your friend if it is compatible to the rest of your environment (e.g. RealURL configuration):
http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html?highlight=prefixlocalanchors

Related

Mystery Markup Generated on Wordpress Footer

I'm having a strange problem with a Wordpress site I built recently, wherein when users visit one of the website's pages via search engine (typically Google), a bit of strange markup is generated inside the footer element. That markup is an unordered list of dates linking to non-existent archive pages, and an unordered list of categories linking to non-existent category pages.
The strange thing here is that there is no code in the theme that would generate this markup, and even more peculiarly, the categories in the unordered list don't exist in the site's database. My first thought was that this could be the result of a possible malware infection, but since the links don't direct the user offsite, that seems unlikely. It would also be strange for the malware to generate problems only when the site is accessed via search engine.
I've been scouring the Internet looking for an example of this occurring, but have yet to find anything, and though I've been working in WP dev for over a year now, this is my first time encountering such a problem. So, my question is this: have any of you encountered something like this before, and if so, do you have any ideas on what could be the problem source, and/or do you have recommendations about how to go about debugging the issue?
NOTE: I have already hidden the markup using CSS for a user-facing solution, so I'm looking for an answer to help me address the problem more sustainably; i.e., finding a way to eliminate the markup in question.
Thanks!!
<ul>
<li><a href='http:/2015/10/'>October 2015</a></li>
<li><a href='http:/2015/09/'>September 2015</a></li>
<li><a href='http:/2015/07/'>July 2015</a></li>
<li><a href='http:/2015/06/'>June 2015</a></li>
</ul>
<ul>
<li class="categories">Categories<ul>
<li class="cat-item cat-item-14"><a href="/category/articlesorder/" >articles,order</a>
</li>
<li class="cat-item cat-item-13"><a href="/category/articlesus/" >articles,us</a>
</li>
<li class="cat-item cat-item-11"><a href="/category/businesswriting/" >business,writing</a>
</li>
<li class="cat-item cat-item-16"><a href="/category/englishorder/" >english,order</a>
</li>
<li class="cat-item cat-item-17"><a href="/category/serviceterm/" >service,term</a>
</li>
<li class="cat-item cat-item-12"><a href="/category/shoolbuy/" >shool,buy</a>
</li>
<li class="cat-item cat-item-18"><a href="/category/studybusiness/" >study,business</a>
</li>
<li class="cat-item cat-item-15"><a href="/category/studypapers/" >study,papers</a>
</li>
</ul></li>
</ul>
Try to change the theme and see if it is the source of this and then disable every plugin and enable one after one to see which of them generates the code.
If this just happens when someones comes from a search engine it is called cloaking.
Please check also the code in your .htaccess and all core files.
You can use Wordfence to scan the files for changes https://de.wordpress.org/plugins/wordfence/

Using php include with multiple sub directories

Hello i recently just got my web server to run all .html files as .php files which now allows me to use the php include function, which is very useful.
However i have multiple sub directories with multiple files in each.
Homepage
--banners
--banner2.html
--banner2.html
--signs
--sign1.html
and so on. The problem here is im trying to use include for my top nav bar. when i include the bar in the sub files, for example banner2.html it wont correctly link.
nav.php
<ul class="nav navbar-nav">
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
<li>
Login
</li>
<li>
Logout
</li>
<li>
<img src="images/Cart.gif" style="height: 20px; width:20px;"> Cart
</li>
</ul>
in the nav bar is a link to about.html normally i would do the
about
however i cant do that when every file is going to share the same navigation bar.
How can I fix this?
I have answered my own quest and feel silly for even asking the question. I just used absoulte paths
nav.php
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
<li>
Login
</li>
<li>
Logout
</li>
<li>
<img src="images/Cart.gif" style="height: 20px; width:20px;"> Cart
</li>
</ul>
There are some ways to fix this, one of them is:
Use $_SERVER["DOCUMENT_ROOT"] – We can use this variable to make all our includes relative to the server root directory, instead of the current working directory(script’s directory). Then we would use something like this for all our includes:
`about`
Also you should check this post.
You could use the relative path to the root directory which is /file.ext
Example:
About

Generated posts from Wordpress-Plugin show empty links in menu

My colleague and I are working on a WordPress-Plugin that generated posts using a custom post type. It all work's fine until You look at the posts. The generated pages look good and use the Themes single.php template. The only problem is, that the menu, that works on all other pages of the site is empty on the pages generated by the plugin.
By empty I mean that the structure including links is there, just the text inside the <a> tags.
The generated menu on a post generated by the plugin looks like this
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
<div class="nav-menu">
<ul>
<li class="page_item page-item-1763">
</li>
<li class="page_item page-item-1761">
</li>
[...]
</ul>
</div>
</nav>
For all other pages, the menu looks like this:
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
<div class="nav-menu">
<ul>
<li class="page_item page-item-1763">
About
</li>
<li class="page_item page-item-1761">
Galerie
</li>
[...]
</ul>
</div>
</nav>
As You can see, the only difference is that there is no text between the <a> and </a> tags, which makes the menu unusable.
We really have no idea of how the plugin / custom-post-type creates this issue, as we tried this with different themes, and they all behave the same - so it is not an issue with the theme.
Any comment or hint that points in the right direction is greatly appreciated.

Bootstrap, nav-tabs, dropdown menus; how to set active tab based on URI

I'm using Bootstrap nav-tabs/dropdown menus component as my primary navigation bar but I cant figure out how to set the active menu based on an incoming URI.
There are a lot of different examples/posts on the net that use nav-tabs for hiding and displaying specific div content or working with the # symbol but I just want to read the incoming URI using PHP, the _SERVER["REQUEST_URI"] variable and set a tab active. Be it a nested location in the navigation or not is also a problem.
Here what I've been trying:
<ul class="nav nav-tabs" id="supernav">
<li class="active"><i class="icon-home" style="margin-top:4px;"></i> Page 1</li>
<li class="dropdown">
Page 2 <b class="caret"></b>
<ul class="dropdown-menu">
<li>Home</li>
<li class="divider"></li>
<li>Page 2.2</li>
<li>Page 2.3</li>
</ul>
</li>
<li class="dropdown">
Page 3 <b class="caret"></b>
<ul class="dropdown-menu">
<li>Home</li>
<li class="divider"></li>
<li class="dropdown-submenu">
Page 3.2
<ul class="dropdown-menu">
<li>Page 3.2.1</li>
<li>Page 3.2.2</li>
</ul>
</li>
</ul>
</li>
<li>Page 4</li>
</ul>
<script>
window.onload=function (e) {
e.preventDefault();
$('#supernav a[href="<?=$_SERVER["REQUEST_URI"];?>"]').tab('show');
};
</script>
Here are a couple URI examples:
http://abc.com/page1.html
http://abc.com/page2.3.html
http://abc.com/page3.2.2.html
Can anyone point me to a good example of how to accomplish this or am I just asking too much from this component?
NOTE: I've preloaded all the bootstrap and jquery resources in my header.
I'm a little late to the party but just came across this post and I figured I'd add my extra 2 cents...
Basically, the best method I've found to set the active bootstrap's tab/pill is by using Javascript/jQuery to match the current url to the href of the active link.
So if your menu is set up as the following:
<ul class="nav nav-tabs">
<li>Page 1</li>
<li>Page 2</li>
</ul>
Your jQuery will be:
$(document).ready(function() {
$('.nav-tabs a[href="'+location.href+'"]').parents('li').addClass('active');
});
This assumes absoulte path for the link's href, but that could be easily overriden by something like:
$(document).ready(function() {
var url_parts = location.href.split('/');
var last_segment = url_parts[url_parts.length-1];
$('.nav-tabs a[href="' + last_segment + '"]').parents('li').addClass('active');
});
Hope this helps somebody in the universe! :)
Cheers!
I've solved my own problem, here is a recap of the goal and what it took to accomplish.
Goals:
I wanted to use the bootstrap nav-tabs component for my navigation
bar because I liked the look/feel of it better.
I wanted to be able to set the 'active' class by parsing the
incoming URI.
I wanted sub-navigation to work as well.
New code based on first post:
<ul class="nav nav-tabs" id="supernav">
<li id="page1"><i class="icon-home" style="margin-top:4px;"></i> Page 1</li>
<li class="dropdown" id="page2">
Page 2 <b class="caret"></b>
<ul class="dropdown-menu">
<li id="page2_home">Home</li>
<li class="divider"></li>
<li id="page2_2">Page 2.2</li>
<li id="page2_3">Page 2.3</li>
</ul>
</li>
<li class="dropdown" id="page3">
Page 3 <b class="caret"></b>
<ul class="dropdown-menu">
<li id="page3_home">Home</li>
<li class="divider"></li>
<li class="dropdown-submenu" id="page3_2">
Page 3.2
<ul class="dropdown-menu">
<li id="page3_2_1">Page 3.2.1</li>
<li id="page3_2_2">Page 3.2.2</li>
</ul>
</li>
</ul>
</li>
<li id="page4">Page 4</li>
</ul>
Notice in the code above that there are no
class="active"
or
data-toggle="tab"
set anywhere.
Because I wanted to make my nav on a static template which is used as a header for all templates I couldn't add any dynamically generated code based on incoming URI's but it turns out not to be necessary.
I added the following Javascript code to bottom of each template a visitor calls to help tell the nav-list which items to be marked as 'active'.
I used this script at the bottom of my /page1.html
<script type="text/javascript">
window.onload=function () {
$('#page1').addClass('active');
};
</script>
To set /page3.2.2.html as the active page and all the nav lvls above it I did this
<script type="text/javascript">
window.onload=function () {
$('#page3').addClass('active');
$('#page3_2').addClass('active');
$('#page3_2_2').addClass('active');
};
</script>
Now when a user comes to my site the nav gets loaded from a static file and the rest of the page contains the dynamic JavaScript that sets what components I want set active.
I also found it necessary to make this one little modification to my custom css in order to make sure no line appeared under my 'active' tab, just a visual thing probably needed because of my font settings.
.nav-tabs > li { margin-bottom: -3px; }
I would have posted some SS's but my 'rep' isn't above 10 yet, ha ha ha. Hopefully this helps someone else, god help us all when version 3 of bootstrap comes out and we have to figure this all out again. 8^)P
Tab is set active on the client-side, not on the server. This is because, usually all the contents of each tab are actually there already in the document on page load. Clicking on a tab simple hides one tab and then shows the tab having the id which the anchor element links to.
Here's what the simplest implementation of Bootstrap's tab looks like:
<!-- tab navigation -->
<ul class="nav nav-tabs">
<li class="active">
Home
</li>
<li>...</li>
<li>...</li>
</ul>
<!-- tab contents are inside -->
<div class="tab-content">
<!-- content of each tab is put inside a tab-pane or tab-pill -->
<div class="tab-pane active" id="tab1">
<p>content of tab 1</p>
</div>
<div class="tab-pane" id="tab2">
<p>content of tab 2</p>
</div>
<div class="tab-pane" id="tab2">
<p>content of tab 3</p>
</div>
</div>
That's not all, you still need to activate tabbing using JS like this:
$('ul.nav.nav-tabs > li > a').click(function(e) {
e.preventDefault();
$(this).tab('show');
});
Based on how your question is constructed, I think you should go have a better look at what each Bootstrap component stands for, and try to understand what are their appropriate use-case.
If your aim was to show a specific tab in response to a request. Simply add the 'active' class to the div element that wraps its content.
And then make it show by doing this:
$('tab-pane active').tab('show');
Note: all you have to do is add active in the right place each time.
For you case specifically, the problem is in your jQuery. Here's the correct way to write it:
$('#supernav active').tab('show');
I was facing similar problem while I had few page urls like : www.somedomain.com/pages/xyz/abc/samplepage.html
This code worked in my case like magic.
$(document).ready(function() {
var permalink_nodomain = window.location.pathname;
$('.nav-tabs a[href="' + permalink_nodomain + '"]').parents('li').addClass('active');
});
May be someone is still looking for this solution just like me :)
Using PHP to set the active isn't the ideal way as PHP is server-side code and the bootstrap is a client-side UI. I recently had a project using bootstrap and found the same issue quite annoying given how powerful bootstrap is and truly hope they fix this in the upcoming 3.0 release.
The way I fixed it was to use jquery to reference a unique id on the link tag and update the active tab value based on that.
So really all the jquery did was remove the active class and assign it to the current clicked link.
If you still want to use the URL path than I'd suggest you use javascript/jquery over PHP. Check out this article on how to do just that. http://css-tricks.com/snippets/javascript/get-url-and-url-parts-in-javascript/
Hope that helps.
Using Bootstrap 4
Given (HAML)
%nav.nav.nav-pills.flex-column
%a.nav-link.active{href: '#users', 'data-toggle'=>'pill', role: 'tab'} Users
%a.nav-link{href: '#deals', 'data-toggle'=>'pill', role: 'tab'} Deals
%a.nav-link{href: '#facilitators', 'data-toggle'=>'pill', role: 'tab'} Facilitators
This is reduced to (Coffeescript)
if location.hash
$('nav.nav-pills a[href="'+location.hash+'"]').tab('show')
Doc: http://v4-alpha.getbootstrap.com/components/navs/#via-javascript

Get only the next page link from Joomla Pagination UL by PHP

I have the following dynamic output generated by Joomla for page navigation.
<ul>
<li class="pagination-start">
<span class="pagenav">Start</span>
</li>
<li class="pagination-prev">
<span class="pagenav">Prev</span>
</li>
<li>
<span class="pagenav">1</span>
</li>
<li>
<a title="2" href="link-to-page-2" class="pagenav">2</a>
</li>
<li class="pagination-next">
<a title="Next" href="link-to-next-page" class="pagenav">Next</a>
</li>
<li class="pagination-end">
<a title="End" href="link-to-last-page" class="pagenav">End</a>
</li>
</ul>
I need only the link data of the next page i.e. link-to-next-page which is wrapped by <li class="pagination-next"></li>
I need to do it in PHP so that I can make use of the same the same for my Infinite Scrolling plugin.
I can do it through jQuery but it will not serve the purpose. I am looking for a PHP solution to get this.
Can someone please help me?
Use the following in your jquery code:
navSelector : '.pagenav', // selector for the paged navigation
nextSelector : '.pagenav a[title="Next"]', // selector for the NEXT link (to page 2)
I have not debugged the above code, simply adapted it from Joomla 1.5 (see here)

Categories