Jump to content

InputTypePage Shortcuts


Mackski
 Share

Recommended Posts

I'm forever writting code like this:

$currency_id = $pages->get($page->currency);
$packages = $pages->get('template=packages, currency='.$currency_id);

Where $page->currency is a page select referencing another page.
It would be great to shortcut this method to something like this:

$packages = $pages->get('template=packages, currency='.$page->currency->getPage()->id');

Or if I wanted to get the title of the currency referenced by the page field:

echo $page->currency->getPage()->title;

So in essence I'm chainging calls to get a page field, the get the corresponding page and retrieve the value of a selected field.

Link to comment
Share on other sites

Have you tried this?

$packages = $pages->get('template=packages, currency='.$page->currency->id);

Perhaps you can leave the last "->id" part too.

If you are using this regularly, create a getPackages function in _func.php that accepts $page as parameter and returns the snippet I wrote above. Thus you could use getPackages($page) when you need it.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...