I am rewriting my website with codeigniter and have something I want to do but not sure it is possible.
I have a gallery on my site powered by the Flickr API. Here is an example of the code I use to display the Landscape pictures:
<?php foreach ($landscapes->photoset->photo as $l->photoset->photo) : ?>
<a href="<?=$l->photoset->photo->farm?>/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id?>/<?=$l->photoset->photo->secret?>/<?=$l->photoset->photo->title?>">
<img class="f_thumb" src="<?=$l->photoset->photo->farm?>.static.flickr.com/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id ?>_<?=$l->photoset->photo->secret ?>_s.jpg" title="<?=$l->photoset->photo->title?>" alt="<?=$l->photoset->photo->title?>" />
</a>
<?php endforeach; ?>
As you can see when a user clicks on a picture I pass over the Farm, Server, ID, Secret and Title elements using URI segments and build the page in the controller using
$data['farm'] = $this->uri->segment(3);
$data['server'] = $this->uri->segment(4);
$data['id'] = $this->uri->segment(5);
$data['secret'] = $this->uri->segment(6);
$data['title'] = $this->uri->segment(7);
Everything works and is fine, but the URL’s are a tad long. Example:
http://localhost:8888/wip/index.php/gallery/focus/3/2682/4368875046/e8f97f61d9/Old_Mill_House_in_Donegal
Is there a way to rewrite the URL so its more like:
http://localhost:8888/wip/index.php/gallery/focus/Old_Mill_House_in_Donegal
I was looking at using:
$url_title = $this->uri->segment(7);
$url_title = url_title($url_title, 'underscore', TRUE);
But I can’t seem to be able to get it to work. Any ideas?
Are the links linking internally? Or are they linking to flickr? If it's internally, I'd suppose you could pass all the requisite information via POST. If it's to flickr, I don't think there is a way you can control how they want requests to come in for a specific item.
What's the endgame/purpose of all that extra info (secret, server, etc)?
Related
I'm trying to create a collage of images that are sourced from a twitter feed to be displayed in a website banner.
So far I have set up the Twitter authentication
I'm not sure how to go about extracting just the images from her feed, or embed them in the desired manner.
Any help or information would be greatly appreciated.
Click here to view a possible outcome I'm looking for.
Thanks!
To simply dump a couple of images, try this:
<?php
require_once("/twitteroauth/twitteroauth.php");
$consumerKey = "0LQwV6gQi1hi8TPOMvfqy7qpM";
$consumerSecret = "AuShkWcg7lj8VYyKYOH6WPW8tY6B2QuB8kgRpmALVrg0VK0mM0";
$accessToken = "624631261-DjWeq4RB0eGAB2lr68skZE1zbfDcg2x6BEyJzFZO";
$accessTokenSecret = "8XnWnkiFQ803r9sHVkDrZNhD50EuJlnw8sZI2EPsA9p7X";
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=%rhyareegaming%20filter%3Aimages&include_entities=true");
foreach ($tweets->statuses as $status) {
?>
<img src="<?php echo $status->entities->media[0]->media_url; ?>">
<?php
}
Ok i have records from database listed in view file, so u can see i wanna pass values to controler via href by update/grab function controler
echo $this->pagination->create_links();
br().br();
foreach ($query->result() as $q): ?>
<?php echo $q->info . br()?>
<?php endforeach; ?>
it works for first page in my pagination, when i am on some other page when i clicked on on record, instead passing parametars to controler when i clicked in keep adding url for example http://localhost/z/records/users/update/grab/3/update/grab/1/update/grab/1/update/grab/1/trtr
So error is when i have in url, when i am on second page in pagination
http://localhost/z/records/users/2
works only when i am on first page
http://localhost/z/records
is there a way to solve this proble. Will it works if i some how adjust routes??? Need help, please help me its very important
Try changing your link to an absolute URL:
<a href="/z/update/grab/<?php echo $q->id;?>/<?php echo $q->info; ?>">
Or adding a correct relative URL base to the header of your pages:
<base href="/z/" />
Codeigniter routes allow you to do this:
$route['post/(:any)/comment/(:any)'] = "posts/comments/$1/$2";
Then in the controller, the function inside my posts controller would work like this:
public function comments($one, $two) {
echo $one."-".$two;
}
so if you hit the url "/post/111/comment/222" the output would be
111-222
I'm using Codeigniter.I want to set href attr to something like :
<a href="/contact.html" >Contact</a>
But i get 404 error because i should write
Contact.
Where is some thing to fix this problem.
Any help please.
Assuming that you have a controller by the name Contact and you successfully extend the CI_Controller class, go to application/config folder and in config.php find:
$config['base_url'] = 'http://www.youdomain.com/';
Then in your internal links you should do:
Contact
If you are using javascript to make the redirect, put on top of the js file:
var host = 'http://www.yourdomain.com/';
Again:
window.location.href = host + 'contact';
If you're using codeigniter, you do not want to point to an .html file.
If you're using codeigniter correctly, you should use the helper methods that exist in codeigniter.
Instead of writing the anchor tag yourself, try this:
<?php echo anchor('contact', 'Contact'); ?>
to add the suffix to your controller in calling go to config/config.php and search for
$config['url_suffix'] = '';
and assign html to it to become
$config['url_suffix'] = 'html';
I wonder if there is a way to add a Warning/Advisory or Terms & Conditions (preferably) to a category or a landing page to warn users about adult content. On the shop I'm working on there is an "Adult Section" Category for Erotic Toys, Lingerie, cosplay, etc. and I need to warn users about such content before they access the section in case they're less than 18.
I've searched the web and only found paid extensions which I cannot afford. Does anyone know how to do this?
I'm using Magento CE 1.7.
Thanks,
EDIT:
Ok, so I've been trying to figure out how to do this and I just figured that the best way to do it would be to just create a Category Landing Page and adding a java script for T&C redirect to the page I want it to.
This is the code I would use for the Category Landing Page with blank content would be this.
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_collectionSize = $_categories->count() ?>
<div>
<?php $i=0; foreach ($_categories as $_category): ?>
<?php
$layer = Mage::getSingleton(‘catalog/layer’);
$layer->setCurrentCategory(Mage::getModel(‘catalog/category’)->load($_category->getId()));
$helper = Mage::helper(‘catalog/category’);
?>
Then I found a code snippet that would redirect the user to a page of my liking after clicking accept but I'm not sure how to implement it and/or if this is the best choice. Here's the code.
<form action="url-to-go-to" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
Now I was thinking that it would be best to just create a simple CMS page and point the category on the top menu to that page and once they have agreed and clicked on continue, they could be taken to the actual category by simply pointing the 'onclick' to the URL of the actual category.
Not sure if this is the best way but it's the only way I could come up. The other way I thought of would've required me to take the "agreements" during checkout that already comes with magento and make an extension that would allow me to place it on any page and call the "Agreement ID" from the Sales/Terms and Conditions tab but I don't know how to actually do that, it was just a thought.
If anyone has a better solution, I'd be happy to hear it.
I would add some sort of JavaScript that shows a div over the top of the whole page, that will create a session cookie when you accept to watch the category. Otherwise, make a back() in the history navigation. This way you don't need another page, just JS.
On another note, could you please post the extensions you found that do this?
Is there any way to get the title of a cms page, if you only know it's url key/identifier? For example, the about page (in the sample data) has a url key/identifier of 'about-magento-demo-store'. If that's the only information I had, how would I go about getting the page title from that? As in the faux code below:
$pageTitle = Mage::getModel('cms/page')->loadByAttribute('identifier', 'about-magento-demo-store')->getTitle();
I'd like to get a list of all CMS page titles, using just the url keys/identifiers.
I know you can get the current CMS page title using the following:
$pageTitle = Mage::getSingleton('cms/page')->getTitle();
Anyone any ideas?
OK, figured it out myself using trial and error:
$pageTitle = Mage::getModel('cms/page')->load('about-magento-demo-store', 'identifier')->getTitle();
I made this solution to get URL-Key (Identifier) of a page:
<?php $pageTitle = Mage::getSingleton('cms/page')->getIdentifier(); ?>
<?php if ($pageTitle=='home'):?>