I'm developing a Joomla 2.5 content plugin that need to programatically create a SEF url when an article is saved.
I've managed to make this work when the regular Joomla SEF is activated. My plugin is using the regular Joomla JRoute::_(); to build a SEF URL. This works great with native Joomla.
For example the url
http://localhost/index.php?option=com_content&view=article&id=123
is translated to
http://localhost/index.php/mycategory/article-title-123.html
My code looks like this:
private function joomlaSefUrl($article){
require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
$siteURL = substr(JURI::root(), 0, -1);
if(JPATH_BASE == JPATH_ADMINISTRATOR) {
// In the back end we need to set the application to the site app instead
JFactory::$application = JApplication::getInstance('site');
}
$articleRoute = JRoute::_( ContentHelperRoute::getArticleRoute($article->id, $article->catid) );
$sefURI = str_replace(JURI::base(true), '', $articleRoute);
if(JPATH_BASE == JPATH_ADMINISTRATOR) {
$siteURL = str_replace($siteURL.DS.'administrator', '', $siteURL);
JFactory::$application = JApplication::getInstance('administrator');
}
$sefURL = $siteURL.$sefURI;
return $sefURL;
}
The problem is that when third party extensions like sh404SEF is installed the SEF URL that I get from using the JRoute::_() method is still the the regular Joomla route url:
http://localhost/index.php/mycategory/article-123.html
instead of the expected sh404SEF's url
http://localhost/Mycategory/article-title.html
Joomla doesn't see that the sh404SEF is installed, so by using the JRoute::(), I allways get the regular SEF Joomla url. So I need to find a way to use the sh404SEF JRoute::() class directly from within my plugin, instead of the regular Joomla router class.
Does anyone know how the sh404SEF classes work?
With Joomla! to get rid of the index.php section of the URL you need to turn on mod_rewrite in you global preferences and enable the .htaccess file that comes with the basic install. (When you first install Joomla! it's called htaccess.txt duplicate and rename the copy to .htaccess
For more complete information read this on Joomla Docs about SEF URLs.
You could try looking at the source of the sh404SEF plugins on JED
Use function getSefFromNonSef in file
administrator\components\com_sh404sef\helpers\general.php
Example:
$url = 'index.php?option=com_content&view=article&id=1:aaaaaaaaa&catid=2&Itemid=101'
$sef_url = Sh404sefHelperGeneral::getSefFromNonSef($url, true, false, null);
Remember, non-sef url, starting with index.php?...
Related
I have created a new Hugo project. By default the urls route to mysite.com/posts/my-first-post. However I'm deploying to an existing domain where the url path for the posts is mysite.com/blog/my-first-post. How can I configure Hugo to go to /blog instead of /posts when view individual blog posts?
I've tried adding:
[permalinks]
post = "/blog/:slug"
To my config.toml file and then running hugo server --disableFastRender so it looks for changes and restarted server but I haven't been able to change the url structure. How might I go about doing this? Currently running anake theme.
Shoulda been posts instead of post.
config.toml
baseURL = "https://connorleech.info/"
languageCode = "en-us"
title = "Connor Leech"
theme = "ananke"
[permalinks]
posts = "blog/:title"
i have added sitemap.xml file to my codeigniter project.
And i call it on my localhost like that : http://localhost/demo/sitemap.xml
it runs without any issue.
But when i run it on live server http://example.com/demo/sitemap.xml
it says 404 page not found.
What is issue ?
you need to add below things in your config/routes.php file
$route['sitemap\.xml'] = 'demo/sitemap'; // your navigation path i.e. your controller_name/function_name
I am trying to make an SEO friendly link for a downloads page
using codeigniter hosted on Azure Websites, now this is working:
www.example.com/downloads/viewfile/34
now when i generated this link :
www.example.com/downloads/viewfile/my-nice-file-name-34
the Url rewrite works great locally on a WAMP server, but when deployed to the remote (Azure Webites IIS ?) it gives the error:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I believe that the cause is: dash symbols are not allowed on IIS but is there a way arround ?
After all, i found out that its not the dash symbols that are causing the problem, but the words in the url itself
like yesterday i had www.example.com/downloads/viewfile/example-file-34
to some reason, having your domain-name in the url segments makes that error apear, so i simply replaced "mydomain" into nothing before generating the Url segment
$fileName = str_replace('mydomain','',$fileName);
return url_title($fileName.$fileId);
Now the same link above is www.example.com/downloads/viewfile/file-34 and its working fine.
i also noticed that same behavior is experienced when using some words like : ajax, json.
I hope this would be helful to somone.
In your routes.php file
Find
$route['translate_uri_dashes'] = FALSE;
Replace with
$route['translate_uri_dashes'] = TRUE;
You may need to look also into
URI Routing Codeigniter 3
http://www.codeigniter.com/user_guide/general/routing.html
Codeigniter 2 URI Routing
http://www.codeigniter.com/userguide2/general/routing.html
I am trying to use a Image Captcha plugin on my website.
Currently I am using google reCaptcha plugin with V2.
But I need a captcha with Image (like Flexible Captcha), I tried using it, but Image dosen't load for this plugin.
I searched for many, but I want it with short code, so that I can place it on my custom forms.
Or If anyone knows how to remove image issue with "Flexible Captcha" plugin, please post your solution.
Edit:
I also tried to use the Securimage-WP plugin as suggested by drew010. Following is the output of plugin:
On Admin settings for plugin:
On Login page:
Note:
My website URL is like http:abc.com/myWebFolder/
Is this thing breaks the plugin to work or it could be the theme issue.
Thanks
My plugin Securimage-WP offers a shortcode for putting a captcha on a custom form.
The plugin also defines a function which you can then call to validate the submitted CAPTCHA.
I have posted a gist here which shows a WordPress page that uses the shortcode on a form and then validates the form and CAPTCHA. Note: Since this page uses PHP, you will need a plugin (I use Exec-PHP) that allows you to run PHP code in posts and pages.
If you need to validate the CAPTCHA in a form processor that is independent of WordPress, you can hook into WP and the plugin by including wp-load.php from the root of your WordPress install.
Comment if you have any questions. Hope this helps!
thank you drew010 for your help, I made complete new installation of wordpress & used your plugin & it worked, then I also used Flexible Captcha plugin & that also worked. Then in order to debug the real problem I add my custom plugin code in new Wordpress. Then it braked. Therefore, to debug more I added each method in my plugin & tested it worked with method. The culprit was following code:
/**/
?>
<?php
function displayLoginForm() {
/*
ob_start();
get_template_part( 'signin-form' );
$ret = ob_get_contents();
ob_end_clean();
return $ret; */
ob_start();
include(ABSPATH . "wp-content/plugins/tus-forms/Views/sign-in.php");
$output = signin_get_clean();
return $output;
}
?>
Changing above into following solved my problem:
function displayLoginForm() {
/*
ob_start();
get_template_part( 'signin-form' );
$ret = ob_get_contents();
ob_end_clean();
return $ret; */
ob_start();
include(ABSPATH . "wp-content/plugins/tus-forms/Views/sign-in.php");
$output = signin_get_clean();
return $output;
}
?>
But I still don't know the real reason behind this issue?
but finally it worked.
Thanks
Captcha On Login This plugin is more flexible with image and its having another feature include of blocking ip and removing ip from blocked. I am using this plugin it is really good.
enter image description here
Im writing a Joomla extension that allows a custom script to run on every "site" page.
I've already done the backend part including database access, but, now I'm completely stuck as to how to add custom javascript to every page of the "site", no matter what theme is installed. Also, I do NOT want to disturb any other stuff on the page.
I have been searching the net for almost 4hours, plus have tried modifying index.php file of templates in various ways, but all in-vain.
Any help?
Thanx in advance...
EDIT
I need to distribute this as an extension...
You need to create a content plugin. For example
class plgContentMyplugin extends JPlugin
{
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
$document = JFactory::getDocument();
$document->addScript(JURI::base().'plugins/content/myplugin/js/myscript.js' );
}
}
This will add myscript.js in the <head>. Just check in docs how to package the plugin