Easy way to kill all links - html

Is there an easy method to kill all links on a Wordpress page? I'm basically stripping down the twenty-eleven theme and pulling it in a simple iFrame on my site to act as a simple news feed. I want to kill all the links, eg - currently, by default, the Wordpress Post titles link to the stand alone posts; just wondering if there's a simple way to void those links with a CSS snippet I can throw in the header, or style sheet.
Edit: To be specific, I want to keep the text of those default links. Just not have them link, so I think display: none; wouldn't work.
I know I could do it manually, just always on the lookout for little tricks - as I feel there could be one, since I don't want any active links on the page.

I guess jQuery could do that for you with something like:
$('a').removeAttr('href');

CSS cannot control this, other than hiding all of the links. You'd need to use JavaScript for this....or edit the PHP source.

Its a bit difficult to determin what you want to do but....
You can hide all links using the css
a {display: none};
Or hit a specific selector or class such as so you would only hide specific links...
a.wp-link {display: none};
You could also do something using javascript such as
(jQuery example)
$("a").attr("href", "#");
This would replace all link urls with a # or what ever you want - so you could also set a redirect.
Finally you could so somthing more sophisticated:
$('a').click(function() {
alert('Site under development...check back soon.');
return false;
});
That (untested) would show an alert if a link was clicked and prevent its default action.
Note all these seem very 'hacky' and if it is a short term fix while you are developing would be acceptable but if you are looking at a long term solution it seems like you need to have a more indepth look at your wordpress set up.

$("a").click(function(e){
e.preventDefault();
})

Related

Run HTML Code upon Button onclick

I have a piece of HTML code for a particular item for sale on a website. This code has all of the information needed for the item, including title, price, dimensions, weight, etc. It also has an "Add To Cart" button included with it.
What I want to do is turn away from Wix and hand-code the entire website using HTML5, CSS3, and Bootstrap 4.1.1. I want to use the same HTML code snippet that I included in Wix, but without the button. I will create my own Bootstrap button.
My question is how do I make it so the code runs when the bootstrap button is clicked?
Thank you.
What you want is JavaScript. Not to split hairs, but HTML is technically not code; it's considered "markup." To get dynamic information, you have to use JavaScript. This might require more conplexity than you realize.
var containerElement = document.querySelector('.container');
var buttonElement = document.querySelector('.button');
var populateContainer = function() {
// do some stuff here
}
buttonElement.onclick = populateContainer;
You may also need some knowledge of a back end language, like PHP, to help you build your shop. For a beginner, I would recommend looking into WordPress so you could install a plugin that handles that stuff for you, like WooCommerce.
Would need more details on what exactly you're trying to do, but Javascript/jQuery is a great way to dynamically make links when a button is clicked.
Assuming you have inputs from the user to get certain product attributes (color/size/etc). You would make it so that when a button is clicked, the jQuery code would check each input and stitch together a URL for you.

MediaWiki: How to update a link status programmatically

My extension renders additional links on a page (that is adds some <a href='...'>...</a> to the page text (in HtmlPageLinkRendererEnd hook)).
See small arrows in https://withoutvowels.org/wiki/Tanakh:Genesis_1:1 for an example. The arrows are automatically added by my extension (sorry, at the time of writing this the source code is not yet released).
The problem is that red/blue ("new") status is not updated for links which I add.
Please explain how to make Wikipedia to update color of my links as appropriate together with regular [[...]] MediaWiki links.
My current workaround is to run php maintenance/update.php. It is a very bad workaround. How to do it better?
Normally you'd use LinkRenderer to create the links and LinkBatch to make the page existence check efficient (you don't want a separate SQL query for each link). You can't really do that in HtmlPageLinkRendererEnd since you only learn about the links one by one.
The way the parser deals with this is that it replaces links with a placeholder and collects them in a list, then after parsing is mostly done it looks them all up at once and then switches the placeholders with the rendered links. You can probably hook into somthing that happens between the two (e.g. ParserAfterParse), get the list of links from the parser and use them to build a list of your own links.
With valuable help of Wikitech-l mailing list, I found a solution.
The solution is to use ParserAfterTidy hook.
public static function onParserAfterTidy( &$parser, &$text ) {
# ...
$parserOutput = $parser->getOutput();
foreach($parserOutput->getLinks() as ...) {
# ...
$parserOutput->addLink( Title::newFromDBkey(...) );
}
}

href - append a parameter to current url without javascript

My webpage url looks like this:
http://mywebsite.com/show-index/index?limit=100
Where limit defines the number of items to display.
I'd like to add a 'show more' which would basically add 'more=true' to my current url:
http://mywebsite.com/show-index/index?limit=100&more=true
I've tried this:
href='?more=true'
But it overides the parameter limit.
Is there a simple way to do it without using javscript?
Thanks
The best would be to do it by Ajax.
If you really don't want to, just use a link
<a href="http://mywebsite.com/show-index/index?limit=100&more=true"</a>
On PHP side, if you detect $_GET['more']='true', juste change the limit to limit+100 in the link.
The best would be to add some achor as #Bartdude says to do not have to scroll each time the page is reloaded.
Don't forget to upvote and mark as solved if you find this useful :)

HTML page title: localization and empty title

2 questions about a better way of solving the problem:
1) is there is a way to make HTML page title looking different for different locales of the client-side code except for javascript?
I.e. write HTML page title which is shown in the browser's tab in corresponding language.
I know I can use javascript for this, but may be there is another way?
2)I set my HTML page header with javascript (it is a different case). But there is a delay before the script will run. Is there is a way to set HTML page header to empty line before javascript evaluates?
If I remove tag I get the page URL.
If I use empty tag - same thing.
I have to use &nbsp content inside which looks a bit ugly.
Some other options?
I don't see any other means but JavaScript on the client side for this, sorry.
For the delay: try using an inline javascript to change the page title right on top of the page before any other scripts are loaded or executed, but after the page title has been set. This should keep the delay to an absolute minimum.
To the first:
Except Javascript, the only Way i know would be PHP, but using Javascript is a lot better and
easier.
To the second:
arkascha's Post is the answer

MediaWiki : is it possible to add an edit link in a template?

I have a template on my wiki, kind of a box template.
Then, there is this page where I use it several times.
Can I add an edit link to each of the boxes so I don't have to edit the whole page in order to modify one of the boxes?
The boxes contain only text, not other templates.
Thanks!
Edit: Actually there's an easier way to ask my question:
Let's say I have a page without sections defined (namely without == titles ==):
content A
content B
content C
Is there a way to open an edit form only for content B?
"Is there a way to open an edit form only for content B?" - in standard mediawiki - no, but you can do sth like this
Main page will look like this:
{{/subpageA}}
{{/subpageB}}
{{/subpageC}}
subpageA will contain link to edit subpageA etc
But it is worse than sections in every possible way.
If I understand your question, and I'm not sure I do, I'm assuming your box is a div or table of some sort? If so, you could add id="{{{1|Some identifying parameter}}} to it.. Now, similar to if you had used == header 2 == you will be able to link to that section of the page with [[{{PAGENAMEE}}#{{{1|Some identifying parameter}}}]]. The only trick is to edit that section. You would likely have to set up a <span class=plainlinks>[http://somewiki.com/edit/{{PAGENAMEE}}&section={{{1|Some identifying parameter}}}]</span> Although, I'm not sure using the section name will work on your wiki, it works on only one of four that I edit. The other three require the section number, which may be harder to figure out, or at very least is beyond my pay-grade atm..
Not sure what you're asking here. Do you want to edit the template from the referring page?
Update:
One: The ugly but simple solution:
Add the following code above the text you want to edit:
=== ===
This will create a section with no name, but with an edit link. If you make four or more of these links, you will create a TOC in the page. You can suppress this with:
__NOTOC__
Two: The neat but extensive solution:
Make your wiki semantic and use Semantic_Forms to edit the page using a form.
Not with the standard installation.
But, I'm sure you could write an extension to do this. Eg. Right click on the page and it will start editing there.
It is possible to add link to edit template, so you can make ugly hack and create separate templates/subpages for every single box.