Keyword

Is it possible to get an item by title match?

  • Kelsey Brookes
  • Kelsey Brookes's Avatar Topic Author
  • Offline
  • Elite Member
More
12 years 11 months ago #102138 by Kelsey Brookes
Is it possible to get an item by title match? was created by Kelsey Brookes
I've got a custom script that's creating automatic links to content based on SEF URLs, but unless the page has been visited at least once, then the URL doesn't exist yet.

But I won't be able to match the readmore of that custom script to an item ID, just an itemTitle - because we're syncing an external database with K2 items, so the itemTitle will always be known.

Is there any way to either generate a link based on an itemTitle or get the item ID by matching an itemTitle?

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #102139 by Lefteris
Hi. You need to generate the alias the same way K2 does or query the database to get the item id:
<?php 
$db = JFactory::getDBO();
$db->setQuery("SELECT id FROM #__k2_items WHERE title = ".$db->Quote($title));
$id = $db->loadResult();

Please Log in or Create an account to join the conversation.

  • Kelsey Brookes
  • Kelsey Brookes's Avatar Topic Author
  • Offline
  • Elite Member
More
12 years 11 months ago #102140 by Kelsey Brookes
Replied by Kelsey Brookes on topic Re: Is it possible to get an item by title match?
Lefteries, that worked a treat - thank you very much!

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #102141 by Lefteris
You are welcome.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum