Help creating extra view mode - template

uhmm… will take a look later this week. But now that I understand what you are building I can help better. The next few days I’m participating on an event, will be harder to answer.

I hope you can relax during the conference. In case you see this message before leaving, I know now how to pass the id of an element to the tainacan_the_metadata function. I would like to use slugs. I can see something related to slugs in the source code of an element page. It is something like this: metadata-slug-tipo-de-documento-2. Do I use the whole text or only the tipo-de-documento-2 string? Do I enclose it in single quotations?

Best regards,

                    Pedro

If you pass the slug of a metadata as an argument like this:

tainacan_the_metadata( array(
    'my-metadata'
));

It is an alternative for passing the ID or the metadata object.

It should fetch the “My Metadata” metadata. What you may be a bit confused by is that the default value for the before attribute (<div class="metadata-type-$type">) makes that the HTML wrapper of the returned metadata contains a class that is in fact the slug of the metadata prepended by metadata-type-.

Tried this code and it is “working”. The regex however may not be returning the desired result, but when I do return the output it seems fine. What exactly are you looking for here? Because if you just want to get rid of the <h4> wrapper (render just the metadata content) you can simply pass:

  tainacan_the_metadata(array(
        'metadata__in' => array($metadata_id),
        'exclude_title' => true,
        'before_title' => '<span hidden>',
        'after_title' => '</span>',
        'before_value' => '',
        'after_value' => ''
    ));

Dear Mateus:

I am using the ‘exclude_title’ option, but I am not able to get only the metadatum value. That is why I had to add the <h4> so that I can look for it in the regex.

I have an alpha version of the template view. If you have a moment, you can try it here:

The view is called “Referencias”.

I am attaching the current version of the plugin. I know that it is not efficient, but it is working. Beside the getting the metadatum value problem, I was not able to get several metadata values into variables in one unique call of the tainacan_the_metadata function. That is why the plugin calls that function several times. I will be very interested in your comments.

Best regards,

                    Pedro 

tainacan-lista-de-referencias.zip (11.0 KB)

The exclude_title is there for avoid fetching the Core Title metadatum. It does not hide the metadatum label, this you can achieve with the before_title => '<span style="display: none;">'.

Will take a look at the link and file later, ok?

Dear Mateus:

Thank you for the tip for getting the metadatum value. It works, but I have not been able of striping the linefeeds before and after the value. I have tried ‘’ and ‘’ in the before-value and after-value, and the trim function but it did not work.

Best regards,

                    Pedro

I have solved the linefeeds problem. I needed the strip_tags function.

I can get rid of the regex in the previous code.

Best regards,

                    Pedro

I’m glad you did it @argeifontesfunes! Can you share you with me the latest version of your code so I can take a look and see if I can give any other suggestion?

Hi Mateus:

At the end, I was not able to use your suggestion, because I need to get the bare metadatum value. With your suggestion, I get a “div” code, even though the page displays only the value. So I kept the “h4” strategy before and after the value so that I can look for the value with the regex. I am attaching the latest version of the plugin.

I have started with my next project: It aims at including in the items’ list links with which the user can download citation RIS file, and an APA reference RTF file for each item. For that purpose, I want to write a script that will generate those files in the server every night for the newly published items. For doing that, I want to call the tainacan_the_metadata function outside the loop. I haven’t been able to. My best try gives me the “no script kiddies, please” message. Could you tell me how I can do that?

Best regards,

                    Pedro 

tainacan-lista-de-referencias.zip (11.3 KB)

Este tópico foi fechado automaticamente 5 dias depois da última resposta. Novas respostas não são mais permitidas.