How to create a modal/popup when link is clicked?

Open to all! Ask other shopowners for help.
Post Reply
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

How to create a modal/popup when link is clicked?

Post by lecarlb »

Hello,

I need a simple modal popup when a link is clicked. I tried the example from the Bootstrap website but it didn't work because I don't know how to properly integrate it into Phoenix.

Thank you.


Join The Code Co-op to get access to your library in the Code Co-op Forum
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: How to create a modal/popup when link is clicked?

Post by heatherbell »

lecarlb wrote: Tue Jul 06, 2021 7:21 am I need a simple modal popup when a link is clicked.
There are a few examples that show how it is done in PRO Supporters Addons e.g. IIRC s02e06 Product Terms has a product_info module that has that behaviour.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to create a modal/popup when link is clicked?

Post by lecarlb »

heatherbell wrote: Tue Jul 06, 2021 7:30 am
lecarlb wrote: Tue Jul 06, 2021 7:21 am I need a simple modal popup when a link is clicked.
There are a few examples that show how it is done in PRO Supporters Addons e.g. IIRC s02e06 Product Terms has a product_info module that has that behaviour.
Thank you for your help. I'm still stuck. I don't know where to begin or where to place the code.
lambro28
Member
Posts: 62
Joined: Sun Jan 03, 2021 2:47 pm
Phoenix Version: v1.1.0.6
Has thanked: 11 times
Been thanked: 8 times

Re: How to create a modal/popup when link is clicked?

Post by lambro28 »

lecarlb wrote: Tue Jul 06, 2021 7:21 am
Thank you for your help. I'm still stuck. I don't know where to begin or where to place the code.
What page(s) do you want the pop to appear on?
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to create a modal/popup when link is clicked?

Post by lecarlb »

lambro28 wrote: Tue Jul 06, 2021 10:30 pm
lecarlb wrote: Tue Jul 06, 2021 7:21 am
Thank you for your help. I'm still stuck. I don't know where to begin or where to place the code.
What page(s) do you want the pop to appear on?
I just want it to pop up when a link is clicked. For example, "Learn more".

It will be in a header module.

Thank you.
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: How to create a modal/popup when link is clicked?

Post by zipurman »

You could read this as it walks you through how to do this in bootstrap.
https://getbootstrap.com/docs/4.6/components/modal/
zipurman
-----------
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to create a modal/popup when link is clicked?

Post by lecarlb »

zipurman wrote: Wed Jul 07, 2021 6:48 am You could read this as it walks you through how to do this in bootstrap.
https://getbootstrap.com/docs/4.6/components/modal/
Thanks. I read that. My issue is where to place that code. Then I know there's some .js that goes along with it. My guess is to place both pieces of code in the module.
Fiber
Contributor
Posts: 173
Joined: Mon Oct 26, 2020 12:16 pm
Phoenix Version: v1.1.0.6
Has thanked: 17 times
Been thanked: 27 times

Re: How to create a modal/popup when link is clicked?

Post by Fiber »

lecarlb wrote: Wed Jul 07, 2021 7:06 am My issue is where to place that code. Then I know there's some .js that goes along with it. My guess is to place both pieces of code in the module.
Why not copy includes/modules/content/header/cm_header_buttons.php and the files associated with it? Rename to the new situation..you don't need part of the code in the template file anymore and delete it and replace the code for the popup, translate properly en turn on in the admin en no core changes :-)
Turn up the Max
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to create a modal/popup when link is clicked?

Post by lecarlb »

Fiber wrote: Wed Jul 07, 2021 9:28 am
lecarlb wrote: Wed Jul 07, 2021 7:06 am My issue is where to place that code. Then I know there's some .js that goes along with it. My guess is to place both pieces of code in the module.
Why not copy includes/modules/content/header/cm_header_buttons.php and the files associated with it? Rename to the new situation..you don't need part of the code in the template file anymore and delete it and replace the code for the popup, translate properly en turn on in the admin en no core changes :-)
I'll try that. Thank you
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: How to create a modal/popup when link is clicked?

Post by burt »

There are a couple of examples of modal in the core code, off the top of my head there is;

1 in advanced_search
1 in create_account (and the same one in checkout_confirmation)

The advanced search one would be easiest to follow I think.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply