ArtcoInc Posted October 8, 2017 Share Posted October 8, 2017 And, if so, can that template be modular and/or Admin configurable? For example, in Edge, there is the Navbar Account module and the Content Footer Account module that both do essentially the same thing. Could they share a common template file? And, could the shared contents be configurable through Admin (ie: add or delete links)? Malcolm Link to comment Share on other sites More sharing options...
ArtcoInc Posted April 6, 2018 Author Share Posted April 6, 2018 I just ran into this again, helping someone add a 'link' to a page they added. I wasted a bunch of time having them edit the /boxes/information files instead of the /content/footer/information_links files. Both display a list of links that presumably should be the same. After all, they both have the same default links ... (yes, I suppose that there may be someone that wants different links in different areas of their store, but ...) Anyway, could it be possible to have both use the same template? Link to comment Share on other sites More sharing options...
♥Tsimi Posted April 6, 2018 Share Posted April 6, 2018 11 minutes ago, ArtcoInc said: Anyway, could it be possible to have both use the same template? The template file contents is usually doing the visual part so I think it should be possible. Isn't there a path to the template file inside the module file? Did you try to change that path to point to the one and same template file? Link to comment Share on other sites More sharing options...
ArtcoInc Posted April 9, 2018 Author Share Posted April 9, 2018 @Tsimi I have not tried this ... I just wanted to ask if anyone had already done this, or knew of problems with doing this. Thanks, though Link to comment Share on other sites More sharing options...
Dan Cole Posted April 9, 2018 Share Posted April 9, 2018 2 hours ago, ArtcoInc said: I have not tried this ... I just wanted to ask if anyone had already done this, or knew of problems with doing this. Thanks, though @ArtcoInc Malcolm I haven't tried this either but if you are using two different modules and are just calling a common template is should be possible by just referencing the correct template file as Lambros pointed out. Give it shot and let us know. Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
burt Posted April 9, 2018 Share Posted April 9, 2018 There is no reason why not. But... Imagine you have a template like this (edge, card acceptance box); <div class="panel panel-default"> <div class="panel-heading"><?php echo MODULE_BOXES_CARD_ACCEPTANCE_BOX_TITLE; ?></div> <div class="panel-body text-center"><?php echo $output; ?></div> </div> and you have a template like this (edge, specials box); <div class="panel panel-default"> <div class="panel-heading"> <?php echo '<a href="' . tep_href_link('specials.php') . '">' . MODULE_BOXES_SPECIALS_BOX_TITLE . '</a>'; ?> </div> <div class="panel-body text-center"> <?php echo '<a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id']) . '">' . tep_image('images/' . $random_product['products_image'], htmlspecialchars($random_product['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link('product_info.php', 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br /><del>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</del><br /><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; ?> </div> </div> You can see that they are broadly similar. What you could do is have ONE template for both as so; <div class="panel panel-default"> <div class="panel-heading"> <?php echo $box_title; ?> </div> <div class="panel-body text-center"> <?php echo $box_content; ?> </div> </div> But then in both module files, you would need to make $box_title and $box_content. Does that make sense ? My idea of "modular" is that each module does its own thing; module file, language file, template file. This way, things are extremely flexible. It's unfortunate that the shopowner you helped the other day did not give all the data you need in his first post. Addendum If you think about it...the following pages all follow a similar "template"; index.php -> product listing products_new.php specials.php advanced_search_result.php All of these use the "template": includes/modules/product_listing.php Link to comment Share on other sites More sharing options...
ArtcoInc Posted April 9, 2018 Author Share Posted April 9, 2018 @burt I recognized that there were enough differences in the way the two templates were formatted to not be able to use one template for both modules. I suppose one could complicate things with if conditions, etc ... but would it be worth it? <shrug> Probably not. Thank you, though. Link to comment Share on other sites More sharing options...
ArtcoInc Posted April 11, 2018 Author Share Posted April 11, 2018 @burt (thinking out loud here ...) Using, for example, the /boxes/information files and the /content/footer/information_links files ... IF the 'data' (the link to each module/page, and the description/title/heading/whatever-you-call-it for each one) was in a database table, both templates could draw the same 'data' from the database. The template could then do what it's supposed to ... to style and format the information. Another bonus would be that as developers create new add-ons, these could auto-populate the database, making the new add-on available with no additional edits or changes. A concern, though, might be the additional database hits with EVERY.SINGLE.PAGE.LOAD. Thoughts? Link to comment Share on other sites More sharing options...
Dan Cole Posted April 11, 2018 Share Posted April 11, 2018 @ArtcoInc Malcolm....what's wrong with having two different template files? It is pretty simple that way and easy to understand. Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
ArtcoInc Posted April 11, 2018 Author Share Posted April 11, 2018 @Dan Cole In my second post above, I mentioned that I was assisting someone here in the forum, and wasted a lot of time having them edit the wrong template. Actually, it all boils down to the case of having to remember to change both templates when adding something to a shop. That's all. Malcolm Link to comment Share on other sites More sharing options...
Dan Cole Posted April 11, 2018 Share Posted April 11, 2018 I do that all the time and I'm told it gets worse. Like you I usually try to find a way to avoid it in the future but sometimes I just have to chalk it up to "having one of those moments again". Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
burt Posted April 11, 2018 Share Posted April 11, 2018 My idea of modularity is that each module is self contained, hence has its own template file. I understand that my idea of modularity is not to the taste of everyone... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.