Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:50:49+00:00 2026-05-23T02:50:49+00:00

I have the following controller view method for my posts: function view($id = null)

  • 0

I have the following controller view method for my posts:

function view($id = null)
{
    $this->Portfolio->id = $id;
    $this->set('posts', $this->Portfolio->read());
}

So currently I pass the id to the view and it shows a post e.g. /portfolio/view/1

However I want to use the Tiny Lib here: https://github.com/kylebragger/tiny/blob/master/tiny.php

for the set I’m using 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

The url I wish to create is e.g. driz.co.uk/portfolio/view/8az/Paperview_Magazine

So basically the 8az part is where Tiny compares the value to the ID in the database

I have created a test link e.g. <?php echo $this->Html->link($post['Portfolio']['title'], array('controller' => 'portfolio', 'action' => 'view', Inflector::slug($post['Portfolio']['title'])), array('title' => $post['Portfolio']['title'])); ?> but not added the Tiny part yet just the inflected post title.

I’ve had a guess at it’s something like the following to do this:

function view ( $tiny_id )  
{
    $id = $this->Tiny->reverseTiny($tiny_id);

    $post = $this->Portfolio->id = $id;

    $this->set('post', $this->Portfolio->read());
}

But I’m stuck with the following:

1.) How to add the Tiny value to my link so I can pass it to the controller/view as currently I’m just passing the inflected URL and not the post id or tiny id

2.) How to use the lib in my method and make sense of it to show the correct post

If anyone can help me with this it’d be much appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:50:50+00:00Added an answer on May 23, 2026 at 2:50 am

    First, to load the Tiny library in your controller, you’ll have to use App::import. I would suggest that you copy the Tiny library in your vendors folder and then use the following in the view action:

    App::import('Vendor', 'tiny');
    

    Make sure that the file named tiny.php is in the vendors folder or it won’t work.

    To generate the link, you should be able to use:

    echo $this->Html->link($post['Portfolio']['title'], array('controller' => 'portfolio', 'action' => 'view', Tiny::toTiny($post['Portfolio']['id']), Inflector::slug($post['Portfolio']['title'])), array('title' => $post['Portfolio']['title']));
    

    To read the post, do the following:

    $this->Postfolio->read(null, Tiny::reverseTiny($id));
    

    The reason why I’m using $id in the reverseTiny call and not $tiny_id like you posted above is because the “view” action expects the first parameter to be the $id (which is the tiny id.) The second parameter, would be the slug, which you function did not explicitly declare. You may want to change the function to:

    public function view($id, $slug) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
Hallo, I have following jquery code for calling ASP.NET MVC controller method that is
I have the following in my routes.rb map.diff 'posts/:id/diff/:from/:to', :controller => posts, :action =>
I'm trying to call a controller method from a javascript function, I read that
I have the following controller file: <?php class Test extends CI_Controller { function __construct()
I have the following controller action and test. I'm new to testing with Shoulda
I have the following code in my controller: public ActionResult Details(int id) { var
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
I have the following in my Global.asax.cs routes.MapRoute( Arrival, {partnerID}, new { controller =
Never thought I'd have this problem :) The following snippet of code works in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.