NextGen Gallery Template V2 for captions under thumbnails

Unfortunately the NextGen gallery V2 templates documentation is a little confusing as some is for the old templates and some is about transitioning to the new. There is no basic page to explain what is going on. The best is here.

Thankfully there are really helpful people on the WordPress.org forum where they have explained various things.

Firstly I wanted to add captions below the thumbnails which was available in a standard template in the legacy setup but as they will be depreciating this shortly I thought I would set up the system properly with the new templates.

lheisey posted a very useful update on their issue which was the same as mine. Firstly you have to create the folder path as out of the box the install does not include this path, this can be done through CPANEL or FTP. The photocrati-nextgen_basic_thumbnails folder and its subfolder templates need to added. Full path is:

wp-content/ngg/modules/photocrati-nextgen_basic_thumbnails/templates/

Then you will need to create a file in the folder called something ending in -view.php. Mine I called test-view.php.

The contents of this file will be exactly the same as the one found at:

wp-content/plugins/nextgen-
gallery/products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/default-view.php

But with some additional code added at lines 55 and 56 (thank you to PostmasterGS in this post), this is slightly different to the code in the post as I could get the text to be visible with just a span, div or even with nested paragraphs inside. A heading with custom CSS solved that. I have used ak suffix so I can track the changes.

Adjusted code:

<div class="ngg-akcustom"><h6><?php if (!$image->hidden) { echo $image->alttext; } ?></h6></div>

In context (snippet from whole file):

 width="<?php echo esc_attr($thumb_size['width'])?>"
                    height="<?php echo esc_attr($thumb_size['height'])?>"
                    style="max-width:100%;"
                />
            </a>
        </div>
        <div class="ngg-akcustom"><h6><?php if (!$image->hidden) { echo $image->alttext; } ?></h6></div>
				<?php

				$this->end_element();

The accompanying CSS:

.ngg-akcustom h6 {
    color: #777;
	font-size: 12px;
	padding-right:5px;
	padding-left:5px;
}

Macros – More Advanced

In my next post on customisation I will be looking at more advanced macro writing. After this post there will be a few individual macro examples which should be helpful!

Please refer to my macro basics and other customisation tutorials first.

In this tutorial I am going to refer to two UCS commands I have written to get around the lack of easy plan rotation in AutoCAD LT. In full AutoCAD you get a rotation box in the upper right corner that looks like the one below. This is unfortunately not available in LT.

Rotate from Viewcube
Rotate from Viewcube

These are a bit more automated version of the tutorial I have posted before as I decided that even that was too much effort!

—–

The first macro rotates the UCS back to world and takes the plan view with it. This avoids the need for UCS follow being set to 1 and the annoying zoom extents bug it has.

^C^Cucs;w;plan;w;

So lets break down the macro above. Its just a simple chain of commands to do with the UCS and PLAN.

  • The first ^C^C at the beginning is escape twice to ensure that the command line is clear
  • Then the UCS command is started
  • Then the UCS command is told to reset to (W)orld
  • Then the PLAN command is started
  • Then the PLAN command is told to reset to (W)orld

Now the drawing is viewed in world view and the UCS is orientated the same way.

——

The second macro rotates the UCS to an object and then updates the view to suit.

^C^Cucs;ob \plan;c;

So lets break this one down as it has something slightly different in its layout.

  • The first ^C^C at the beginning is escape twice to ensure that the command line is clear
  • Then the UCS command is started
  • Then the UCS command is told to select by object
  • Then the script waits for input by the use of a space then a backslash
  • Then the PLAN command is started (after input)
  • Then the PLAN command is told to update to the (C)urrent

——

This formula can be used to make further buttons to emulate the plan rotate found in full AutoCAD or make any chain of commands work.

A quick way to create a macro is to run a command and follow the command line and write down your inputs and once you have completed the command you have the basics for putting together a macro.

—–

Lets make a macro to rotate the UCS and PLAN to the right. Here is a copy of the command line and below that is a list of the command inputs and then the resultant macro.

Command line:

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: z
Specify rotation angle about Z axis <90.00>: 90
Command: PLAN
Enter an option [Current ucs/Ucs/World] <Current>: c
Regenerating model.

Command input only:

ucs
z
90
plan
c

Macro:

^C^Cucs;z;90;plan;c;

Ribbon Creation – My First Ribbon

So in my previous post, I went through the basics of the CUI editor, now I will run through the creation of a ribbon and populate that with panels and commands.

CUI file creation

In order to not disturb the main CUI file for AutoCAD and also make the customisations portable we will need to create our own file to contain the customisations.

To do this, go to the Transfer tab in the CUI editor and go to the right hand column and click on the icon next the drop down box that states “New File”.

Custom_createnewcuifile
Create New CUI file

This will bring up a windows file dialog. Browse to where you want to save this and remember where it was as we will need it for the next step.

Once you click OK you will be returned to the Transfer tab.

Now click on the customise tab and go to the drop down under “customisations in main file” and click open. Or you can click the folder icon next to this drop down (there is a third way to load files but I will run through that later).

Custom_opencuifile
Open CUI file

This will open the blank CUI file that was created in the previous step.

 

Create a New Ribbon

New Tab

Once you have your CUI open, make sure it is selected in the drop down rather than ACADLT.CUIX (or similar). Here it is called TEST.CUIX

Custom_newtab
New Ribbon Tab

The tree now displayed is everthing you can customise. There is a lot there! We will focus on the Ribbon section for now.

Click the plus next to the Ribbon and you will see TABS, PANELS and CONTEXTURAL TAB STATES listed. For now we are going to look at TABS and PANELS.

Right click on the word TAB and click “new tab”.

New panel

Once we have a panel we will be able to add them to the tab. Next up, right click on the word PANEL and click “new panel”.

Custom_newpanel
New ribbon panel

I have called my panel, test panel. You will see that it has a launcher icon and an another icon called ROW 1. Under the rows is where you place your commands in order for them to show up on the ribbon.

There are three rows in the ribbon. If you need more the slideout is there to allow a larger panel. On my custom ribbon I have a slideout for lesser used layer commands that I sometimes use and find it hard to find in the other ribbon tabs.

Under each panel you can have sub-panels. This is a mini panel that has its own rows. This allows for large buttons and drop downs to be mixed with smaller buttons.

 

Custom Command

Lets add a new command. This is where scripting comes in. In the full version of AutoCAD you can call LISPs and write DIESEL commands straight into a button command (note that LISP and DIESEL are programming languages and will require knowledge of these to undertake).

However in LT you are limited to only MACROS. MACROS look complicated but are actually a representation of the command line inputs, just in one line.

Custom_createcommand1
Create Command step 1

You will notice that the command list is empty as this CUI file contains no commands.

In order to create one, click the little star to the right of the “All Commands Only” drop down.

Custom_createcommand2
Create Command step 2

I have called my command “test command”. Once created you will get a new properties box on the right with name, description etc. listed.

The main items to fill in are the name and the macro. This will create a button with a command built into it.

Here we are going to create a button that launches the plot dialog box.

The MACRO code for this (see my macro basics for an explanation):

^C^Cplot;

Once the MACRO is inserted we will assign an icon so it can be seen easily.

Custom_assignimage1
Assign Image Step 1

Click on the small arrows on the properties and the button image selection box will be shown. You can assign images, create new ones etc. here.

You can also load an external file for the icon by clicking in the image box and then the three dots to the end of the box (see above image).

Here we are going to use the built in icon for plotting.

Custom_assignimage2
Assign image step 2

 

Making the Ribbon

Once you have completed the command. Drag the command from the command list to the ribbon panel row1 (see above). The command is now assigned to that panel.

Then drag the panel to the tab. The panel is now assigned to the tab.

Click Apply and then OK.

Your Ribbon should now appear at the end of the ribbon list.

Custom_completedribbon
Completed Ribbon

If it doesn’t appear you can use the third method (mentioned earlier) of loading a CUI file. Type CUILOAD and a little box will appear.

Custom_cuiload
CUI Load

Click your CUI file name and click “unload”. Now click “browse” and go where you cui was saved and then click “load”. Then click close. The ribbon should now work. I have found this works most of the time whilst loading within the CUI editor fails more often.

NOTE:
DO NOT click on the ACADLT one at the top and then click “unload”, this will break things horribly. If you do, you will need to browse to the ACADLT customisation file and load it again (this is usually stored under your profile in windows, for LT 2015 this is under “C:\Users\yourusername\AppData\Roaming\Autodesk\AutoCAD LT 2015\R21\enu\Support”

Ribbon Creation – The CUI Editor

Previously I reviewed the basics behind why Ribbons are here and I will now continue to how one is created or edited using the editing inferface in AutoCAD.

In order to edit or create a ribbon you must first enter the editor that comes with AutoCAD for this purpose. Don’t worry it is built into AutoCAD so you won’t need to install a seperate program. This is called the CUI (or Customise User Interface).

It can be accessed by typing CUI on the command line,

Custom_wheretofilecuieditbutton3
CUI from command line

 

or by going to the menu: tools –> customise interface

Custom_wheretofilecuieditbutton2
CUI from menu

 

or as most of you will be using the Ribbon now (I hope!) you can find it under Manage.

Custom_wheretofilecuieditbutton1
CUI editor from Ribbon

 

Once you have the editor open you will probably be confused. There are many panes and sub-directories and other items that appear daunting. However I will break it down and actaully it is quite simple and fairly logical in the end!

All information for AutoCAD’s interface is stored in various files. More on those in a moment.

Custom_cuidialogbox
CUI dialog box

So we have two tabs, CUSTOMISE and TRANSFER and three panes PROPERTIES, CUSTOMIZATIONS IN ALL FILES and COMMAND LIST.

—–

Customise Tab

The CUSTOMISE tab is most of the work is done, under the “customisations in main file” section, there is a drop down. This lists the main customisation file (above the first line) usually called ACAD.CUIX or ACADLT.CUIX, however this could change on a vertical platform. I would not work on these as an upgrade could wipe any settings. Instead I would create a new file (that comes a little later).

There are usually a couple of files listed in the second section of this drop down, in full AutoCAD this is where express tools is loaded and under LT you usually get content explorer listed here. These are called partial customisation files as they do not contain information regarding the entire interface, rather only a part. We will be creating one of these partial files later on.

If you select one of these files the command list at the bottom changes to reflect the commands stored in that CUI file.

The properties on the right will display the properties of the current object selected, be it a CUI file, a ribbon, a toolbar or just a command.

Tranfer tab

The TRANSFER tab allows varies commands etc. to be moved from one file to another. Simples.

 

Ribbon Creation – Introduction

Previously AutoCAD had toolbars. These were easier to customise as you only had one component to edit. That is a blank toolbar to add buttons to.

The ribbon is slightly more complex as you have a blank ribbon that you add panels to and a blank panel that you add buttons to.

Theis complexity however allows for a greater amount of permutations and layout design. This functionality is intentional from the design inception allows for greater customisation than a set of toolbars could ever do. You can have larger buttons, drop down button selection and even context sensitve ribbons.

In this series I go through creating a ribbon, adding a panel, adding a button and then work through various button scripts that I have created over the years that might be of use for your new ribbon.

I have been using my custom ribbon since 2009 and whilst it keeps evolving its basic layou has not changed and I tend to have all my frequently used items on this one bar. This reduces the number of clicks considerably in a day!

Macros – Basics

In order to create custom commands and then assign them to a button in AutoCAD you will need to create a MACRO. This is so for all buttons, even those that call a LISP or OBJECTARX piece of code.

The MACRO is basically a list of the inputs on the command line listed out in one line.

A simple MACRO would look like this:

^C^Cplot;

This if turned placed in a button would bring up the plot dialog box.

The ^C^C is the code for pressing “escape” twice. This clears any active commands in case one is running.

The ; is the representation of enter. Any number of commands can be strung together into one MACRO.

MACROs also allow for input for selecting objects and this is written with a space and then a backslash.

I will be running through several of my custom commands to show how they are put together.

Customisation Category

Customising AutoCAD can be quite daunting so I thought I would produce a few posts to run through the process of customisation from creating a new Ribbon tab and ribbon panels from scratch through to adding your own buttons.

Button creation is probably the most important as they can contain scripts to optimise and speed up many tasks.

These posts will be within the Customisation Category.