Skip to main content

Project in Project (Nested Projects)

🔗 Original page — Source of this material


Description

*Project in Project lets you link an already finished, recorded project to your current project. This action is similar to ❗→ *Plugins.

How to add the action to a project?

Via the context menu: Add actionProjectProject in Project

image-20200813-072309

Or use the ❗→ smart search.

Use Cases

  • Most commonly, *Project in Project is used for repeated sections:
    • Example: You're working with a site. You have several separate templates for this site: product parser, user parser, message sender. To work with the site, you need to be logged in. Each of these templates has the same logic segment — checking whether the user is logged in, and if not, logging in. A good solution would be to take this login check and Auth logic out into a separate small sub-template and connect it wherever needed. Then in the future, if you want to update how authorization is handled, you'll only need to make changes in one place—the sub-template (instead of editing multiple templates)—which significantly reduces the chance of making a mistake.
  • You can also put universal functions in sub-projects that can be used across different templates:
    • text generation
    • checking text for uniqueness
    • uploading images to image hosting, and much more
  • Another possible use is splitting up one large template into sub-templates
    • Sometimes templates get really huge, especially when it's an "all-in-one" tool for working with some resource: registrar, parser, checker, sender. Splitting one big template into smaller parts and connecting those parts as *Project in Project (rather than keeping everything in one) is a good idea. Then, you set only the main settings in the base template.
  • Any template can be used as a nested template, and just like with *Plugins, the only limit here is your imagination

How to work with this action?

Basic Settings

image-20200813-083014

Path to the nested project

Here you specify the absolute path to the sub-template (you can use macros for ❗→ variables). In the screenshot, you can see the { -Project.Directory- } variable—the path to your project's current folder. To have this variable entered automatically when writing your project, enable the ❗→ corresponding setting).

Pass project context (project.Context)

❗→ project.Context lets you save C# objects and transfer them between different parts of the template. This option is used when working with ❗→ C# code.

Open browser if needed

Enabling this setting allows the nested template to launch the ❗→ browser even if it's disabled in the main project via ❗→ Project settings

Passing Variables

image-20200813-083220

Mapping Variables

In this window, you transfer data from the outer project to the inner one. Data can only be transferred via variables.

Match variables with the same name

If this option is enabled, all variables with identical names in both projects will be automatically matched, saving you from manual setup.

Attention

Manual matching takes precedence over "Match variables with same name". Example: if you enable "Match variables..." and both projects have a variable named variable, but you manually, in the settings, map the variable from the inner project to a different variable in the outer project, say second_var, then the variable from the inner project will now be associated with second_var from the outer project.

Do not send variable values back if action fails

By default, all changes to variables in the inner project also affect the outer project's variables. If you enable this setting, the variable changes will be ignored by the outer project if the inner one finishes with an error.

Example Usage

One example is sending yourself notifications via email.

You can create a template that, based on the email address you provide, automatically determines the settings to connect to the server. All you need to do is send the message text, sender info, and recipient info from the main project.

image-20200813-091819

Selling templates containing nested projects

If you're selling your templates that use nested projects, don't forget about the ❗→ commission.

Project Load Error

image-20201228-131135

If, while creating a project, you see a window like this and in the log there's an error like "Action ProjectInProject Error during processing", then it's very likely that the problem is that you're trying to run a locked template on inactive hardware.

To fix this, go to your Personal Account, Equipment tab and activate the hardware you're currently working on.

Search for .zp projects during "Project in Project" action execution

Info

Added in ZennoPoster 7.4.0.0

When you enable ❗→ this setting, if the action uses a project in the old .xmlz format but that file is missing, ZennoPoster will search for a project with the same name but the new .zp extension.

.xmlz - ZennoPoster project extension used in ZennoPoster 5 and below
.zp - project extension currently used in ZennoPoster 7.