File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -350,6 +350,21 @@ def get_modules_info():
350350 pass
351351 return modules_info
352352
353+ def get_content (type_name , limit = None , order = 'desc' ):
354+ from modules .contenttype .models import ContentType , ContentItem
355+ ct = ContentType .query .filter_by (name = type_name ).first ()
356+ if not ct :
357+ return []
358+ query = ContentItem .query .filter_by (content_type_id = ct .id )
359+ if order == 'desc' :
360+ query = query .order_by (ContentItem .created_at .desc ())
361+ else :
362+ query = query .order_by (ContentItem .created_at .asc ())
363+
364+ if limit :
365+ return query .limit (limit ).all ()
366+ return query .all ()
367+
353368 base_context = {
354369 "APP_NAME" : APP_NAME ,
355370 "OUR_APP_NAME" : APP_NAME ,
@@ -362,7 +377,8 @@ def get_modules_info():
362377 "get_active_front_theme" : get_active_front_theme ,
363378 "get_active_back_theme" : get_active_back_theme ,
364379 "get_modules_info" : get_modules_info ,
365- "get_url_prefix" : get_url_prefix
380+ "get_url_prefix" : get_url_prefix ,
381+ "get_content" : get_content
366382 }
367383 base_context .update (global_template_variables )
368384
You can’t perform that action at this time.
0 commit comments