I want pagination url with out href url link in codeiginter - codeigniter

I have use codeiginter pagination functionality. But I want pagination url with out href url link in codeiginter. how can possible please help?

you can play with Pagination library , create your own library like so
application/libraries/Pagination.php
and copy the content of CI native pagination library file into the file that you just created from
system/libraries/Pagination.php
so this way you don't touch core files
then search for "here we go..." in my version it is on line 225
underneath you can see how those links are rendered and you can change them as you wish
// And here we go...
$output = '';
// Render the "First" link
if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
{
$first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
$output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
.... etc
you can read more about Replacing and extending Native Libraries with Your Versions here http://www.codeigniter.com/userguide2/general/creating_libraries.htmll
hope that helps!

Related

How to display correct link in CI anchor

I have a form with upload file option.
I get the file_path on $data uploaded by user. Now I want to use this
file_path to be the link in my anchor tag.
My problem is i can't get the correct link. it seems like that the base URL was being included in the link showed in the lower left of the screen.
I also read some post here to add "http://" before the link. but the link appeared was like this
c/xampp/htdocs/.../uploads/products/filename.pdf
no colon.
any idea on how can I access my uploaded file be access via link.
Thanks
paste this line in your /applications/config/config.php just right before
$config['base_url'] = "";
and change this to
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https://' : 'http://');
$root = $protocol.$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
This approach makes your base_url() function returns the current host or url you are in. Even if you upload this to any server it will always return the exact url of your website.
Then you use it like this
<?= base_url('uploads/products/filename.pdf'); ?>
That's all you have to do. Hope this helps!

Joomla! - Load editor-xtd plugin layout from specified file in button's iframe handler

I'm working on a Joomla! 2.5/3.x editor-xtd button and I have a problem loading a layout from file on button click.
I have tried this method:
$link = 'plugins/editors-xtd/myplugin/myplugin.layout.php?name='.$name;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = 'Insert something';
$button->name = 'myplugin';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";
... but the full generated link in admin looks like http://my.local.host/mywebsite/administrator/plugins/editor-xtd/link-etc.. and it doesn't work. I also have tried including JURI::base in my $link, but the administrator path is still loaded.
I'm new in plugin dev with Joomla! and I have search a lot but no solution found.
** I also tried a link like this index.php?folder=plugins.editors-xtd.myplugin&file=myplugin.layout.php&name=$name but still nothing.
Is there a workout for this or I'll have to create&use a javascript function to run on button click?
Solution
Modify link variable like this (if application is admin):
$link = '../plugins/editors-xtd/myplugin/myplugin.layout.php?name='.$name;
... and delete button options (this means that file contents will be loaded via ajax inside modal)
Further more, in myplugin.layout.php we can add a little security check and we can import Joomla! framework library and defines so that we can make use of Joomla! framework in our file (things like language load for eg.)
This is my actual header of file:
<?php
// No direct access
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
if( ! IS_AJAX) die;
// Include J!Framework for later use
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..'));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php');
//more magic goes here...
Unfortunately there is a bit of a gotcha here in that the JED checker process requires that ALL php files start with defined('_JEXEC') or die; on the very first line of code so if you want to share it on extensions.joomla.org then you are stymied...
Back on the OP you can detect whether you are in the Admin or Site before generating the link:
$app = JFactory::getApplication();
// ...
if ($app->isAdmin()) {
$root = '../'; // Joomla expects a relative path, leave site folder "administrator"
} else {
$root = '';
}
$button->link = $root.'/plugins/editors-xtd/myplugin/myplugin.layout.php?name='.$name;
Also, as you may already know the $button->name = 'myplugin'; needs to be the name of the icon from the Joomla icomoon set - you can see them here https://ma.tvtmarine.com/en/blog/112-joomla-icomoon-icons-directory
The name needs to be the icon name without the .icon- bit eg:
$button->name = 'warning-2';
code block doesn't seem to be working properly...sorry about the formatting

Manually control <head> markup in Joomla

Is there a way to manually configure the contents of the <head> section of the site in Joomla 3.1? I want to use the templating system for the entire markup of the page, including everything between <html></html>.
I just read this: http://forum.joomla.org/viewtopic.php?f=466&t=230787 and I am astonished at the response. Surely this is template/data separation 101. Has this been fixed in the latest Joomla release?
If you are planning for a template development and you need all your template data get separated from Joomla libraries or core file (the head section).
Normally the head section include will works like
<jdoc:include type="head" />
it loads the content from libraries libraries\joomla\document\html\renderer\head.php
If you want to override the content of head you can make a module for your task.
Just create a module and include that module instead of this head make sure that have all required codes added to work $document Class otherwise it miss a lot off features of Joomla regarding document class
As explained by the answer from Jobin, normally, you would include the head data by using the <jdoc:include type="head" /> tag, but if you want more control over this, you can use the JDocument.
Example code in your template's PHP:
$doc = JFactory::getDocument();
$my_head_data = $doc->getHeadData();
This will give you an array of the data that JDocument would normally print, so that you can completely choose what to print and how.
To make jQuery load from CDN and get it on top of the script list, I made a little patch just after the $doc = JFactory::getDocument(); that manipulates the header array directly inside the $this object as follows:
$my_jquery = "//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js";
$my_jquery_ui = "//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js";
$my_jquery_cx = $this->baseurl."/media/jui/js/jquery-noconflict.js ";
foreach($this->_scripts as $k=>$v) {
// put own jquery.conflict && jquery-ui && jquery on top of list
if( strpos($k,'jquery.min.js')) {
unset($this->_scripts[$k]);
$r = array( $my_jquery_cx => $v);
$this->_scripts = $r + $this->_scripts;
$r = array( $my_jquery_ui => $v);
$this->_scripts = $r + $this->_scripts;
$r = array( $my_jquery => $v);
$this->_scripts = $r + $this->_scripts;
}
else if( strpos($k,'jquery.ui.min.js')) {
unset($this->_scripts[$k]);
}
else if( strpos($k,'jquery-noconflict.js')) {
unset($this->_scripts[$k]);
}
}
Replace $my_jquery_xxx with editable config parameters in your templateDetails.xml file

How to redirect WORDPRESS hotlinked image ( for exp : Image.jpg) to post/page where it is?

Recently google change image search and as a result most of the traffic click over view original image and it send them to direct image file.
I have changed my .htaccess and stop all hot linking and redirect to my homepage if they click over image file.
Recently I've also tried if it is possible to redirect to post or page where image is.
By the following code
<?php
require('../wp-blog-header.php');
$imageURL = strip_tags( $_GET['id'] );
if imageURL!== "") {
$query = "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment'AND post_parent > '0' AND guid = '$imageURL'";
$linkedImage = $wpdb-get_row($query);
$attachmentUrl = get_attachment_link($linkedImage->ID);
if($attachmentUrl !== "" && !is_numeric(stripos($attachmentUrl, "attachment_id=0"))) {
header("HTTP/1.1 302 Found");
header("Location: ". $attachmentUrl);
exit;
}
}
$newUrl = get_site_url() . "/image-not-found";
header("HTTP/1.0 404 Not Found");
header("Location: " . $newUrl);
exit;
?>
But it redirect to http://www.mydomain.com/?attachment_id=
id is nil or can't fetch the proper id
My website in Wordpress CMS version 3.5.1
can anyone help how to redirect to proper attachment page for .jpg file direct request.
Thanks in advance
Your code would only work if there was an ID parameter on the requested URL that would be an exact match with the image URL, for instance http://www.example.com/?id=http://www.example.com/uploads/Some-Image.jpg
Is this the case? Even so, you shouldn't use id since it's a reserved parameter for other things in WP. In your .htaccess, you should redirect http://www.example.com/uploads/Some-Image.jpg to, for example, http://www.example.com/?image_redirect=http://www.example.com/uploads/Some-Image.jpg. Then use $imageURL = $_GET['image_redirect'].
Other notes: strip_tags doesn't make a string safe to use as a SQL query. In WordPress, you have esc_sql($string) for that. Also, you should rather use if ( $imageUrl != '' ), not with !==. And there's an error on line 5, it should say $wpdb->get_row, you currently have a minus sign. I assume these are typos. And finally, you shouldn't use Location: header with a status code 404.

Render module in the right position from code (Joomla 2.5)

In my component view, I can show a module by this code:
$module = JModuleHelper::getModule('mod_login');
$html = JModuleHelper::renderModule($module);
echo $html;
or
echo JHtml::_('content.prepare', '{loadmodule login}');
But that will usually place the module in the middle of the screen in the main-content div.
How can I place the module in the position defined in the module params?
Take a look at how the admin template Isis renders the quickicons module on the home page or at how the error page in protostar renders the search modules.
$this->searchmodules = JModuleHelper::getModules('position-0');
foreach ($this->searchmodules as $searchmodule)
{
$output = JModuleHelper::renderModule($searchmodule, array('style' => 'none'));
$params = new JRegistry;
$params->loadString($searchmodule->params);
echo $output;
}
You just want one module, but you get the basic idea.
Try This.
You can Pass the module parameters too.
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$Module = &JModuleHelper::getModule('mod_fmDataGrid');
$Params = "param1=bruno\n\rparam2=chris";
$Module->params = $Params;
echo $renderer->render($Module);
This may help you..
You can't, jdoc includes in the template are processed after the component has finished producing its output.
Why not let Joomla render the modules in the right positions? that should be one of the reasons for using it, i.e. taking care of placement and order of modules.
If you have other reasons for doing this, please explain further.

Resources