Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning custom function #1068

Open
damianxd opened this issue Oct 1, 2024 · 10 comments
Open

Assigning custom function #1068

damianxd opened this issue Oct 1, 2024 · 10 comments

Comments

@damianxd
Copy link

damianxd commented Oct 1, 2024

I've been reading and trying different methods but I haven't been able to assign variables from a custom tag. Something like:
{8ball var1='num' assign='result'}
{$result}

I saw that I could use a custom tag inside the assign tag, like this:
{assign var="returndata" value={8ball var1='num'}}
but that doesn't work with arrays as the return for the custom tag.

Is there any way to achieve this?
Thanks for the help

@wisskid
Copy link
Contributor

wisskid commented Oct 1, 2024

Use {capture}{/capture}?

@wisskid
Copy link
Contributor

wisskid commented Oct 1, 2024

Probably won't work with arrays either.

@mohrt
Copy link
Contributor

mohrt commented Oct 1, 2024 via email

@damianxd
Copy link
Author

damianxd commented Oct 2, 2024

I've tried to use this:
https://www.smarty.net/docs/en/plugins.functions.tpl

and set the output with the template assign function, it works and I managed to use the the variable on the template, the downside is that I get a lot of files on the template compile folder:
Screenshot 2024-10-02 at 9 43 39 AM
Any ideas on how to avoid creating so many compiled files? The site is quite big and has a lot of traffic, using this would mean the server would go out of free inodes in just some days.

@mohrt
Copy link
Contributor

mohrt commented Oct 2, 2024 via email

@damianxd
Copy link
Author

damianxd commented Oct 2, 2024

it's a big site with an old version of Smarty (3.x) and I'm trying to update it to 5. I have no chance of changing the whole design of the site in the amount of time I got, there are functions starting a {include} in case some conditions have been met and a lot of subdivision on each one of the pages, it would take ages to move everything into php.

@mohrt
Copy link
Contributor

mohrt commented Oct 2, 2024 via email

@damianxd
Copy link
Author

damianxd commented Oct 2, 2024

It's just a lot of those {insert} tags, but I see they are now deprecated

@mohrt
Copy link
Contributor

mohrt commented Oct 2, 2024 via email

@damianxd
Copy link
Author

damianxd commented Oct 2, 2024

Since it's already documented, I hope someone knows how to use this: https://www.smarty.net/docs/en/plugins.functions.tpl without generating an external compiled file for the string and add it to the tpl compiled file instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants