Codeigniter summernote fail result - codeigniter

I am using the codeigniter framework with the summernote editor.
If I use a single page in php post without the framework, the result is just like this:
<span style="font-weight: bold;">asdasdasd</span>
But if I use post in codeigniter the result is different, like this:
<span bold;">asdasdasd</span>
style='font-weight: ' is missing..
Why did it happen, and what is the solution?
Thank you for helping.

I got the answer...
in codeigniter don't use :
$_POST['content'] OR $_GET['content']
but use :
$_REQUEST['content']
PROBLEM SOLVED!

I think that is a xss filter problem, try to disable or get the value to false.
$content = $this->input->post('content', FALSE);
I've edited with original summernote example:
<div class="span12">
<h2>POST DATA</h2>
<pre>
<?php print_r($this->input->post(NULL, FALSE)); ?>
</pre>
<pre>
<?php echo htmlspecialchars($this->input->post('content', FALSE)); ?>
</pre>
</div>

Related

How to use Microdata for URLs in Joomla?

I read here about Microdata in Joomla. However, I'm not able to produce a link with Microdata.
I want a Microdata output like:
<a itemprop="url" href="http://someurl">
<span itemprop="name">Some Url</span>
</a>
I want a link to an organisation from my client's website. My code is:
$microdata = new JMicrodata('Organization');
<div <?php echo $microdata->displayScope();?>>
echo $microdata->content( $this->item->url )->property( 'sameAs' )->display();
// outputs <span itemprop="sameAs">www.url_of_company.com</span>
</div>
Both url and sameAs Schema.org properties are of type URL, as per my understanding.
I also tried to wrap it with an anchor tag but Joomla is not producing itemprop along with href attribute in anchor tag.
I must be missing something.
Ok I analysed in libraries/joomla/microdata/microdata.php the method display();
and it doesn't exist any way to produce a <a href="#" > tag, only div, span and meta.
Btw there is a static method called htmlProperty(), with that you can add the property you need.
<?php $microdata = new JMicrodata('Organization'); ?>
<div <?php echo $microdata->displayScope(); ?> >
<a <?php echo JMicrodata::htmlProperty('url'); ?> href="http://google.com">
<?php echo $microdata->content('Google')->property('name')->display(); ?>
</a>
</div>

How to show content of a a specific URL in Smarty template?

Following is my code snippet from smarty template :
<div id="entrancelist">
<h2 class="heading">My Packages</h2>
{if $user_study_test_packages.test}
<ul class="entrancelist">
{foreach from=$user_study_test_packages.test item="user_test_packages" key=key}
<li>
<h4>{$user_test_packages.pack_name|capitalize:true}</h4>
{if $user_test_packages.pack_expiry_date1 >= $current_date }
<div class="fr"><span class="expiry">Expiry : {$user_test_packages.pack_expiry_date}</span></div>
{else}
<div class="fr"><span class="expiry_dt">This package is expired on {$user_test_packages.pack_expiry_date}.</span></div>
{/if}
<p class="descp">{$user_test_packages.test_pack_desc}</p>
<div class="srtest"> </div>
</li>
{/foreach}
</ol>
{else}
You haven't bought any online test packages
{/if}
</div>
Now what I want to do is reaplace the text "You haven't bought any online test packages" with the content of different URL say www.google.com But I'm not understanding how should I achieve this. Can anyone help me out in this issue? Thanks in advance.
Why not keep PHP separate from the template?
Maybe do this in your php code,
<?php
$gcontent = file_get_contents('http://www.google.com');
$smarty->assign('gcontent',$gcontent);
?>
Then you can use {$gcontent} in your template.
You can even use query string parameters with the URL if you wanted to. More info on the php function.
http://www.w3schools.com/php/func_filesystem_file_get_contents.asp
Something like this works for me in Smarty 3, but some might not consider it very elegant:
...
{else}
{file_get_contents('http://www.google.com/')}
{/if}

Getting the thumbnail URL from getChildrenCategories()

I've been driving myself crazy trying to display thumbnail images for a list of sub categories I'm attempting to display in a footer. I've tried the solution found here: http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/ but no luck!
Here is the code I am using at the moment. Everything works fine apart from the img src renders empty:
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan):
?>
<li>
<img src="<?= $artisan->getThumbnailUrl() ?>" />
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
Any help would be greatly appreciated! Thanks in advance.
SOLUTION (thanks Lucasmus!):
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan): ?>
<li>
<img src="<?= Mage::getBaseUrl('media').'catalog/category/'.$artisan->load($artisan->getId())->getThumbnail() ?>" width="96" height="96" />
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
There is a good chance that there is not enough information loaded from the childcategory. It could help if you added $artisan->load($artisan->getId()); before getting the actual variables from the $artisan.
If you try $artisan->getThumbnail() instead of $artisan->getThumbnailUrl()? I think that is the correct attribute name.
yeah but the $artisan->getThumbnailUrl() calls $artisan->getThumbnail()
so why dont you in you script first set a thumbnail value you know exists for the getthumbnail() to call.
then you'll know it's a db naming problem

Suggest an AJAX solution to form submission without reloading page, with action="" instead of action="response.php"

I have a search page: (please excuse the bad syntax, just for demo purposes)
<form action="" method="post" name="form">
//form elements and such with a hidden input name="action" value="search"
</form>
<?php if(isset($_POST['action']) and $_POST['action'] == 'search'): ?>
<?php include results.php ?> //takes form data, build SQL query, puts results in array
<?php foreach($results as result) blah blah //for each result display it ?>
<?php endforeach; ?>
<?php endif; ?>
I've seen solutions where the action attribute is set to a php file. Unfortunately in my example it doesn't have one. Take this one: http://www.simonerodriguez.com/ajax-form-submit-example/
<form name="MyForm" action="response_ajax.php" method="post" onsubmit="xmlhttpPost('response_ajax.php, 'MyForm', 'MyResult', '<img src=\'pleasewait.gif\'>'); return false;">
It looks nice but unfortunately I don't have the first parameter required: reqsponse_ajax.php, mine is just blank.
The JS can be found here: http://www.simonerodriguez.com/wp-content/plugins/downloads-manager/upload/ajaxsbmt.js
If anyone can make modifications to the script or suggest a better solution, that'll be awesome, thanks.
it shouldn't matter at all what's in the action attribute when you're using AJAX. it's the onsubmit or the submit button's onclick attribute that starts the AJAX processing.
you do understand the basics of AJAX, right? instead of actually submitting the form, which would load a new page, you send an XMLHttpRequest to the server, POSTing the data, and wait for an answer back with onreadystatechange, at which point you dynamically update your page. there are literally hundreds if not thousands of examples of this on the web.

Show only next and previous link in condeigniter pagination

I use codeigniter pagination class in my project it's works fine for me . But there is no option to tell class just show next and previous link ,
please see this image I want to show result paged plus I'd like to use to link for next and previous instead of numeric links and when the user click on the next button I'll use Ajax to retrieve request I don't have problem with Ajax calls in pagination in numeric links but I want to just show this to link :)
I don't think I can explain what I need very good so please see the image .
link text
Here is my view file :
<div style="height:200px; position:relative">
<div id="left_nav"></div>
<div id="right_nav"></div>
<div style="width:622px;margin:0 auto;">
<!-- Gallery Box1 -->
<?php foreach($last_profile as $l) : ?>
<div id="galleryBoxHolder">
<div id="galleryBoxContent">
<div id="ImageHolder">
<img src="dummy_data/1.gif" /> </div>
<br />
<p><?=$l->artname?> </p>
<br />
<p style="color:#1a4688">asdasd</p>
<p style="color:#1a4688 ; direction:ltr"><?=$l->length?> cm x <?=$l->width?> cm</p>
</div>
</div>
<?php endforeach ;?>
<div>
<?=$links?>
</div>
<!-- Gallery box1 :off -->
</div>
</div>
Please Check This url which is exactly what I need (#:title Customers Who Bought This Item Also Bought)
In version 2.0.3 Codeigniter - To show Next / Previous only you can add the following config settings:
$config['display_pages'] = FALSE;
$config['first_link'] = FALSE;
$config['last_link'] = FALSE;
You have a couple of options. The first is really simple, hide the thumbnails portion of the pagination module with CSS. The second options isn't too complex either: modify the pagination class to not include the thumbnails, and instead limit its output to the next/prev buttons. This should be somewhat trivial as well.
Line 199 of the System/Libraries/Pagination Library is where the "digits" are handled. This is where you will remove any appending to the $output variable:
if ($this->cur_page == $loop)
{
$output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
}
else
{
$n = ($i == 0) ? '' : $i;
$output .= $this->num_tag_open.''.$loop.''.$this->num_tag_close;
}

Resources