Forum Activity for @the-patria-company

PatriaCo
@the-patria-company
11/21/18 07:59:49PM
349 posts

Img Tag Override to Amp-Img


Jamroom Developers

I have tried adding this code to my AMP module's include.php, but it is not working. Can someone spot the problem?

function ampify($html='') {

    # Replace img, audio, and video elements with amp custom elements

    $html = str_ireplace(

        ['<img','<video','/video>','<audio','/audio>'],

        ['<amp-img','<amp-video','/amp-video>','<amp-audio','/amp-audio>'],

        $html

    );

    # Add closing tags to amp-img custom element

    $html = preg_replace('/<amp-img(.*?)\/?>/', '<amp-img$1></amp-img>',$html);

    # Whitelist of HTML tags allowed by AMP

    $html = strip_tags($html,'<h1><h2><h3><h4><h5><h6><a><p><ul><ol><li><blockquote><q><cite><ins><del><strong><em><code><pre><svg><table><thead><tbody><tfoot><th><tr><td><dl><dt><dd><article><section><header><footer><aside><figure><time><abbr><div><span><hr><small><br><amp-img><amp-audio><amp-video><amp-ad><amp-anim><amp-carousel><amp-fit-rext><amp-image-lightbox><amp-instagram><amp-lightbox><amp-twitter><amp-youtube>');

    return $html;
}
PatriaCo
@the-patria-company
11/17/18 09:29:58PM
349 posts

Img Tag Override to Amp-Img


Jamroom Developers

I need a bit of help writing a listener and trigger that will override the jrCore > jrImage_display function on a mobile device.

#1. I need to be able to add params to the jrImage_display function such as:
amp-width, amp-height & the amp "layout" attribute (of course these need to be ignored when not on a mobile device)

#2. It must allow the "img" tag to be replaced by the "amp-img" tag for everything to be amp valid.

Is this possible? I already have a functioning AMP module, I just need to add this piece for it to really integrate with the image functionality of JR.

THANKS!! :)
updated by @the-patria-company: 03/04/19 08:20:22PM
PatriaCo
@the-patria-company
10/25/18 10:18:03AM
349 posts

Custom Module Pages in Sitemap


Jamroom Developers

Three words: Jamroom IS Awesome!!

We start with the includes.php and make sure that there is a listener registered and coded properly:

function myCustomModule_init(){
    // Add pages to sitemap
    jrCore_register_event_listener('jrSitemap', 'sitemap_site_pages', 'myCustomModule_sitemap_site_pages_listener')
    
    return true;
}

function myCustomModule_sitemap_site_pages_listener($_data, $_user, $_conf, $_args, $event)
{ $url = jrCore_get_module_url('myCustomModule'); $_data[] = "{$_conf['jrCore_base_url']}/{$url}/my-custom-module-page"; return $_data; }

Now, because we all want to meet the strictest SEO standards, make sure that your custom page in your module has hyphens in the URL (and NOT underscores) add this page view function to your index.php like this:

function view_myCustomModule_default($_post, $_user, $_conf)
{ switch ($_post['option']) { case'my-custom-module-page': return jrCore_parse_template('my-custom-module-page.tpl', $_rep, 'myCustomModule'); break; } }

And "Voila!" you now have a custom page, SEO ready and entered in your sitemap!
PatriaCo
@the-patria-company
10/23/18 08:30:03AM
349 posts

Custom Module Pages in Sitemap


Jamroom Developers

Ok, I'm still a module novice, so let me give this a try. Since my module does not have a schema.php it is NOT a datastore module. Correct? If that is the case I need to add the listener to the include.php? What should that line of code look like exactly?

jrCore_sitemap_site_pages ('jrCore', 'something', 'myCustomModule', 'enabled')

I feel like I am off in left field on this one. ;)

Thanks for your help.
PatriaCo
@the-patria-company
10/23/18 08:02:13AM
349 posts

Custom Module Pages in Sitemap


Jamroom Developers

How can I ensure that pages created using a module's index.php are included in the sitemap?
updated by @the-patria-company: 04/14/19 10:04:53PM
PatriaCo
@the-patria-company
10/21/18 07:18:55AM
349 posts

Use Module Template File in jrCore_list


Jamroom Developers

How can I use a .tpl from a module in a jrCore_list call?

{jrCore_list module="jrProfile" search1="...   ...template="example.tpl"}

Using this version, the .tpl file must be located in the skin directory. When I update the skin the file is removed. In order to avoid this down-time I would like to call a template directly from my custom module.

What param should I add to make this work?
updated by @the-patria-company: 01/19/19 09:52:20PM
PatriaCo
@the-patria-company
10/19/18 12:21:42PM
349 posts

Create Basic Info Page in Module


Jamroom Developers

THAT WAS ABSOLUTELY PERFECT!!! Exactly what we needed. Thank you so much!!!
PatriaCo
@the-patria-company
10/17/18 07:19:42AM
349 posts

Create Basic Info Page in Module


Jamroom Developers

Reading further, there is apparently still a negative effect on SEO when using the underscore in the URL title.
https://www.woorank.com/en/blog/underscores-in-urls-why-are-they-not-recommended

Is it possible to rewrite the URL to use a hyphen?

I tried
view_pcTradesPlumbers_alabama-plumbers()
but it did not work.

It would be best for SEO to have the URL read /residential-commercial-plumbers/alabama-plumbers

Is it possible to use history.pushState in the view function?

Sorry for my hesitations, I don't want to cause a major js conflict that will cost me hours of work just to undo.

Thanks!

*additional thought*
or would it be better to create a selection array in the function to display city and state similar to the way the event calendar does month and year?

view_pcTradesPlumbers_usa()
$location


/residential-commercial-plumbers/usa/birmingham-alabama
updated by @the-patria-company: 10/17/18 11:40:14AM
  6