Answers.Body: <p>Try using <a href="http://buildwithcraft.com/classreference/services/ElementsService#getElementByUri-detail" rel="nofollow">ElementsService</a>:</p>
  
  <pre><code>$entry = craft()-&gt;elements-&gt;getElementByUri( 'blog/article1' );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T23:56:27.420Z
Answers.Text: That was a whole lot easier then I expected. I was looking on the routing services, did not even think to look on the element service. Thank you!
Answers.UserDisplayName: Nicholas LeBlanc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T00:11:52.580Z
Answers.Text: No worries – it's often like that with Craft, no? :)
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T23:33:44.770Z
Answers.LastActivityDate: 2015-03-05T23:33:44.770Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I'm trying to get an element from it's URL. </p>
  
  <p>For example, say we have a url of <code>http://craft.dev/blog/article1</code>. Is there a function I can call within a plugin and pass over <code>blog/article1</code> that will return a corresponding element, if one exists, for that specific URL? I'm sure there is a way to do this with the router, I'm just not sure what it is.</p>
  
Tags: <plugin-development><url><localization>
Title: Lookup element by URL
ThreadText: # Lookup element by URL
  
  (Asked by: username_0 on 2015-03-05)
  
  I'm trying to get an element from it's URL.
  
  For example, say we have a url of `http://craft.dev/blog/article1`. Is there a function I can call within a plugin and pass over `blog/article1` that will return a corresponding element, if one exists, for that specific URL? I'm sure there is a way to do this with the router, I'm just not sure what it is.
  
  **Tags:** plugin-development, url, localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-05. Score: 2 | Accepted answer
  
  Try using [ElementsService](http://buildwithcraft.com/classreference/services/ElementsService#getElementByUri-detail):
  
  ```
  $entry = craft()->elements->getElementByUri( 'blog/article1' );
  
  ```
  
  > **Comments:**
  > **username_0**: That was a whole lot easier then I expected. I was looking on the routing services, did not even think to look on the element service. Thank you!  
  > **username_1**: No worries – it's often like that with Craft, no? :)  
  
  ---
  
  